diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 00000000..d683ade3 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +DJANGO_SETTINGS_MODULE = settings.testing \ No newline at end of file diff --git a/requirements-devel.txt b/requirements-devel.txt new file mode 100644 index 00000000..c2187e13 --- /dev/null +++ b/requirements-devel.txt @@ -0,0 +1,6 @@ +-r requirements.txt + +factory-boy==2.3.1 +py==1.4.20 +pytest==2.5.2 +pytest-django==2.6.1 diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/auth/__init__.py b/tests/auth/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/auth/test_api.py b/tests/auth/test_api.py new file mode 100644 index 00000000..eb1390be --- /dev/null +++ b/tests/auth/test_api.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +import pytest +from unittest import mock + +from rest_framework.reverse import reverse + +from ..factories import DomainFactory + +pytestmark = pytest.mark.django_db + + +def setup_module(module): + module.patcher = mock.patch("taiga.domains.base.get_default_domain", DomainFactory.build) + module.patcher.start() + + +def teardown_module(module): + module.patcher.stop() + + +def test_respond_400_if_credentials_are_invalid(client): + response = client.post(reverse("auth-list"), {"username": "john", "password": "smith"}) + assert response.status_code == 400 diff --git a/tests/factories.py b/tests/factories.py new file mode 100644 index 00000000..96a325f7 --- /dev/null +++ b/tests/factories.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +import factory + +from taiga.domains import models + + +class DomainFactory(factory.DjangoModelFactory): + FACTORY_FOR = models.Domain + + public_register = False + scheme = None + name = "localhost" + domain = "localhost"