-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|
||
|
@@ -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") |