diff --git a/src/apps/dashboard/tests/integrated/__init__.py b/src/apps/dashboard/tests/integrated/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/apps/dashboard/tests/test_forms.py b/src/apps/dashboard/tests/integrated/test_forms.py similarity index 85% rename from src/apps/dashboard/tests/test_forms.py rename to src/apps/dashboard/tests/integrated/test_forms.py index a515536..dcf504a 100644 --- a/src/apps/dashboard/tests/test_forms.py +++ b/src/apps/dashboard/tests/integrated/test_forms.py @@ -1,18 +1,15 @@ from django.test import TestCase -from ..forms import ( + +from apps.dashboard.forms import ( DUPLICATE_ITEM_ERROR, EMPTY_ITEM_ERROR, ExistingListItemForm, ItemForm, ) -from ..models import Item, List +from apps.dashboard.models import Item, List + class ItemFormTest(TestCase): - def test_form_validation_for_blank_items(self): - form = ItemForm(data={"text": ""}) - self.assertFalse(form.is_valid()) - self.assertEqual(form.errors["text"], [EMPTY_ITEM_ERROR]) - def test_form_save_handles_saving_to_a_list(self): mylist = List.objects.create() form = ItemForm(data={"text": "do re mi"}) diff --git a/src/apps/dashboard/tests/test_models.py b/src/apps/dashboard/tests/integrated/test_models.py similarity index 90% rename from src/apps/dashboard/tests/test_models.py rename to src/apps/dashboard/tests/integrated/test_models.py index 1ef27ae..5c82c39 100644 --- a/src/apps/dashboard/tests/test_models.py +++ b/src/apps/dashboard/tests/integrated/test_models.py @@ -1,14 +1,12 @@ from django.core.exceptions import ValidationError from django.db.utils import IntegrityError from django.test import TestCase -from ..models import Item, List + +from apps.dashboard.models import Item, List from apps.lyric.models import User + class ItemModelTest(TestCase): - def test_default_text(self): - item = Item() - self.assertEqual(item.text, "") - def test_item_is_related_to_list(self): mylist = List.objects.create() item = Item() @@ -42,10 +40,6 @@ class ItemModelTest(TestCase): item = Item(list=list2, text="nojk") item.full_clean() # should not raise - def test_string_representation(self): - item = Item(text="sample text") - self.assertEqual(str(item), "sample text") - class ListModelTest(TestCase): def test_get_absolute_url(self): mylist = List.objects.create() diff --git a/src/apps/dashboard/tests/test_views.py b/src/apps/dashboard/tests/integrated/test_views.py similarity index 99% rename from src/apps/dashboard/tests/test_views.py rename to src/apps/dashboard/tests/integrated/test_views.py index 244ab81..4ea42d5 100644 --- a/src/apps/dashboard/tests/test_views.py +++ b/src/apps/dashboard/tests/integrated/test_views.py @@ -1,13 +1,14 @@ import lxml.html from unittest import skip + from django.test import TestCase from django.utils import html -from ..forms import ( +from apps.dashboard.forms import ( DUPLICATE_ITEM_ERROR, EMPTY_ITEM_ERROR, ) -from ..models import Item, List +from apps.dashboard.models import Item, List from apps.lyric.models import User diff --git a/src/apps/dashboard/tests/unit/__init__.py b/src/apps/dashboard/tests/unit/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/apps/dashboard/tests/unit/test_forms.py b/src/apps/dashboard/tests/unit/test_forms.py new file mode 100644 index 0000000..209ebf5 --- /dev/null +++ b/src/apps/dashboard/tests/unit/test_forms.py @@ -0,0 +1,13 @@ +from django.test import SimpleTestCase + +from apps.dashboard.forms import ( + EMPTY_ITEM_ERROR, + ItemForm, +) + + +class SimpleItemFormTest(SimpleTestCase): + def test_form_validation_for_blank_items(self): + form = ItemForm(data={"text": ""}) + self.assertFalse(form.is_valid()) + self.assertEqual(form.errors["text"], [EMPTY_ITEM_ERROR]) diff --git a/src/apps/dashboard/tests/unit/test_models.py b/src/apps/dashboard/tests/unit/test_models.py new file mode 100644 index 0000000..1e004bc --- /dev/null +++ b/src/apps/dashboard/tests/unit/test_models.py @@ -0,0 +1,13 @@ +from django.test import SimpleTestCase + +from apps.dashboard.models import Item + + +class SimpleItemModelTest(SimpleTestCase): + def test_default_text(self): + item = Item() + self.assertEqual(item.text, "") + + def test_string_representation(self): + item = Item(text="sample text") + self.assertEqual(str(item), "sample text") diff --git a/src/apps/lyric/tests/integrated/__init__.py b/src/apps/lyric/tests/integrated/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/apps/lyric/tests/test_authentication.py b/src/apps/lyric/tests/integrated/test_authentication.py similarity index 85% rename from src/apps/lyric/tests/test_authentication.py rename to src/apps/lyric/tests/integrated/test_authentication.py index 7828269..dc54fbd 100644 --- a/src/apps/lyric/tests/test_authentication.py +++ b/src/apps/lyric/tests/integrated/test_authentication.py @@ -2,17 +2,11 @@ import uuid from django.http import HttpRequest from django.test import TestCase -from ..authentication import PasswordlessAuthenticationBackend -from ..models import Token, User +from apps.lyric.authentication import PasswordlessAuthenticationBackend +from apps.lyric.models import Token, User class AuthenticateTest(TestCase): - def test_returns_None_if_token_is_invalid_uuid(self): - result = PasswordlessAuthenticationBackend().authenticate( - HttpRequest(), "no-such-token" - ) - self.assertIsNone(result) - def test_returns_None_if_token_uuid_not_found(self): uid = uuid.uuid4() result = PasswordlessAuthenticationBackend().authenticate( diff --git a/src/apps/lyric/tests/test_models.py b/src/apps/lyric/tests/integrated/test_models.py similarity index 94% rename from src/apps/lyric/tests/test_models.py rename to src/apps/lyric/tests/integrated/test_models.py index 46e65c5..d6db7d0 100644 --- a/src/apps/lyric/tests/test_models.py +++ b/src/apps/lyric/tests/integrated/test_models.py @@ -1,7 +1,9 @@ import uuid from django.contrib import auth from django.test import TestCase -from ..models import Token, User + +from apps.lyric.models import Token, User + class UserModelTest(TestCase): def test_model_is_configured_for_django_auth(self): diff --git a/src/apps/lyric/tests/test_views.py b/src/apps/lyric/tests/integrated/test_views.py similarity index 98% rename from src/apps/lyric/tests/test_views.py rename to src/apps/lyric/tests/integrated/test_views.py index 191d483..92219b2 100644 --- a/src/apps/lyric/tests/test_views.py +++ b/src/apps/lyric/tests/integrated/test_views.py @@ -1,7 +1,10 @@ from django.contrib import auth from django.test import TestCase from unittest import mock -from ..models import Token + +from apps.lyric.models import Token + + class SendLoginEmailViewTest(TestCase): def test_redirects_to_home_page(self): diff --git a/src/apps/lyric/tests/unit/__init__.py b/src/apps/lyric/tests/unit/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/apps/lyric/tests/unit/test_authentication.py b/src/apps/lyric/tests/unit/test_authentication.py new file mode 100644 index 0000000..75f47f6 --- /dev/null +++ b/src/apps/lyric/tests/unit/test_authentication.py @@ -0,0 +1,12 @@ +from django.http import HttpRequest +from django.test import SimpleTestCase + +from apps.lyric.authentication import PasswordlessAuthenticationBackend + + +class SimpleAuthenticateTest(SimpleTestCase): + def test_returns_None_if_token_is_invalid_uuid(self): + result = PasswordlessAuthenticationBackend().authenticate( + HttpRequest(), "no-such-token" + ) + self.assertIsNone(result)