1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-29 14:59:55 +00:00
bramw_baserow/backend/tests/baserow/contrib/automation/test_object_scopes.py
2025-04-17 17:01:26 +04:00

27 lines
725 B
Python

from unittest.mock import MagicMock
from django.db.models import Q
import pytest
from baserow.contrib.automation.object_scopes import AutomationObjectScopeType
@pytest.mark.django_db
def test_raises_if_scope_type_invalid():
mock_scope = MagicMock()
mock_scope.type = "foo"
with pytest.raises(TypeError) as exc_info:
AutomationObjectScopeType().get_filter_for_scope_type(mock_scope, [])
assert str(exc_info.value) == "The given type is not handled."
@pytest.mark.django_db
def test_get_filter_for_scope_type():
mock_scope = MagicMock()
mock_scope.type = "automation"
result = AutomationObjectScopeType().get_filter_for_scope_type(mock_scope, [])
assert result == Q(id__in=[])