Skip to content

Commit

Permalink
Edge case testing
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Jul 18, 2024
1 parent 9c052e8 commit dd17656
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion projects/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.test.utils import override_settings

from accounts.models import User
from projects.models import Catalog, Project
from projects.models import Catalog, Event, Project
from projects.translators import TranslationError, fix_nls


Expand Down Expand Up @@ -444,3 +444,43 @@ def test_fix_nls(self):
]:
with self.subTest(test=test):
self.assertEqual(fix_nls(test[0], test[1]), test[2])

def test_event_save(self):
user = User.objects.create_superuser("[email protected]", "admin")
p = Project.objects.create(name="test", slug="test")
c = p.catalogs.create(
language_code="fr",
domain="djangojs",
pofile="",
)

p2 = Project.objects.create(name="test2", slug="test2")

e = Event.objects.create(
user=user,
action=Event.Action.CATALOG_CREATED,
catalog=c,
)
self.assertEqual(str(e), "created catalog")
self.assertEqual(e.project, p)

e = Event.objects.create(
user=user,
action=Event.Action.CATALOG_CREATED,
catalog=c,
project=p2, # Makes no sense but is allowed
)
self.assertEqual(str(e), "created catalog")
self.assertEqual(e.project, p2)

e = Event.objects.create(
action=Event.Action.CATALOG_CREATED,
)
self.assertEqual(str(e), "created catalog")

e = Event.objects.create(
user=user,
action=Event.Action.CATALOG_CREATED,
project=p2,
)
self.assertEqual(str(e), "created catalog")

0 comments on commit dd17656

Please sign in to comment.