-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #637 from drnlm/bugfix/fix_test_discovery
Bugfix/fix test discovery
- Loading branch information
Showing
7 changed files
with
103 additions
and
95 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
Empty file.
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,41 +1,47 @@ | ||
from datetime import timedelta | ||
from django.utils import timezone | ||
|
||
from wafer.talks.models import TalkType | ||
|
||
|
||
def test_open_by_default(): | ||
talk_type = TalkType.objects.create() | ||
assert talk_type in TalkType.objects.open_for_submission() | ||
|
||
|
||
def test_closed_when_flagged_as_such(): | ||
talk_type = TalkType.objects.create(disable_submission=True) | ||
assert talk_type not in TalkType.objects.open_for_submission() | ||
|
||
|
||
def test_open_for_submission_by_date(): | ||
now = timezone.now() | ||
yesterday = now - timedelta(days=1) | ||
tomorrow = now + timedelta(days=2) | ||
|
||
closed_talk_type = TalkType.objects.create(submission_deadline=yesterday) | ||
open_talk_type = TalkType.objects.create(submission_deadline=tomorrow) | ||
disabled_talk_type = TalkType.objects.create( | ||
submission_deadline=tomorrow, | ||
disable_submission=True, | ||
) | ||
|
||
assert open_talk_type in TalkType.objects.open_for_submission() | ||
assert closed_talk_type not in TalkType.objects.open_for_submission() | ||
from django.test import TestCase | ||
|
||
from wafer.talks.models import TalkType | ||
|
||
def test_open_for_late_submissions(): | ||
now = timezone.now() | ||
yesterday = now - timedelta(days=1) | ||
|
||
talk_type = TalkType.objects.create( | ||
submission_deadline=yesterday, | ||
accept_late_submissions=True, | ||
) | ||
assert talk_type in TalkType.objects.open_for_submission() | ||
class TestTalkTypes(TestCase): | ||
"""Collection of tests for talk type handling.""" | ||
|
||
def test_open_by_default(self): | ||
"""Check that types are open for submission by default""" | ||
talk_type = TalkType.objects.create() | ||
self.assertTrue(talk_type in TalkType.objects.open_for_submission()) | ||
|
||
def test_closed_when_flagged_as_such(self): | ||
"""Check that the closed submission flag works""" | ||
talk_type = TalkType.objects.create(disable_submission=True) | ||
self.assertTrue(talk_type not in TalkType.objects.open_for_submission()) | ||
|
||
def test_open_for_submission_by_date(self): | ||
"""Check taht we can use dates to manage open/ closed state""" | ||
now = timezone.now() | ||
yesterday = now - timedelta(days=1) | ||
tomorrow = now + timedelta(days=2) | ||
|
||
closed_talk_type = TalkType.objects.create(submission_deadline=yesterday) | ||
open_talk_type = TalkType.objects.create(submission_deadline=tomorrow) | ||
disabled_talk_type = TalkType.objects.create( | ||
submission_deadline=tomorrow, | ||
disable_submission=True, | ||
) | ||
|
||
self.assertTrue(open_talk_type in TalkType.objects.open_for_submission()) | ||
self.assertTrue(closed_talk_type not in TalkType.objects.open_for_submission()) | ||
|
||
def test_open_for_late_submissions(self): | ||
"""Check that types that allow late submissions stay open""" | ||
now = timezone.now() | ||
yesterday = now - timedelta(days=1) | ||
|
||
talk_type = TalkType.objects.create( | ||
submission_deadline=yesterday, | ||
accept_late_submissions=True, | ||
) | ||
self.assertTrue(talk_type in TalkType.objects.open_for_submission()) |
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
Empty file.