-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add model tests; rename app in admin
- Loading branch information
1 parent
c864bf6
commit 689b829
Showing
3 changed files
with
56 additions
and
5 deletions.
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
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
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 |
---|---|---|
@@ -1,4 +1,46 @@ | ||
from event.models import LetterEventDate | ||
|
||
|
||
def test_letter_action_name(letter, letter_action): | ||
action_str = str(letter_action) | ||
|
||
assert str(action_str) == f'writing of {str(letter)}' | ||
assert str(action_str) == f"writing of {str(letter)}" | ||
|
||
|
||
def test_letter_event_date_with_exact_date(letter_action): | ||
letter_event_date = LetterEventDate.objects.create( | ||
letter_action=letter_action, | ||
year_exact=500, | ||
) | ||
assert ( | ||
str(letter_event_date) | ||
== f"writing of {str(letter_action.letters.first())} (500)" | ||
) | ||
|
||
|
||
def test_letter_event_date_with_date_range(letter_action): | ||
letter_event_date = LetterEventDate.objects.create( | ||
letter_action=letter_action, | ||
year_lower=500, | ||
year_upper=600, | ||
) | ||
assert ( | ||
str(letter_event_date) | ||
== f"writing of {str(letter_action.letters.first())} (c. 500–600)" | ||
) | ||
|
||
|
||
def test_world_event(world_event): | ||
world_event.year_exact = 500 | ||
world_event.save() | ||
assert str(world_event) == "Test World Event (500)" | ||
|
||
|
||
def test_world_event_trigger(world_event, epistolary_event): | ||
world_event.epistolary_events.add(epistolary_event) | ||
world_event.save() | ||
|
||
trigger = world_event.epistolary_events.through.objects.first() | ||
|
||
assert str(trigger) == "Test World Event (612) triggered Test Epistolary event" | ||
|