Skip to content

Commit

Permalink
Fakes and mocks are gremlins. (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahboyce committed Nov 15, 2023
1 parent 8b9119f commit cb7f44d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions home/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ def is_accepting_applications(self):
aoe_late_timezone = datetime.timezone(datetime.timedelta(hours=-12))
today_early_aoe = datetime.datetime.now(tz=aoe_early_timezone).date()
today_late_aoe = datetime.datetime.now(tz=aoe_late_timezone).date()
return (self.application_start_date.date() <= today_early_aoe) and (
today_late_aoe <= self.application_end_date.date()
return (self.application_start_date <= today_early_aoe) and (
today_late_aoe <= self.application_end_date
)

def get_absolute_url(self):
Expand Down
13 changes: 8 additions & 5 deletions home/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ class SessionTests(TestCase):
@classmethod
def setUpTestData(cls):
cls.session = Session.objects.create(
start_date=datetime(2024, 1, 15),
end_date=datetime(2024, 3, 11),
start_date=datetime(2024, 1, 15).date(),
end_date=datetime(2024, 3, 11).date(),
title="2024 Session 1",
slug="2024-session-1",
invitation_date=datetime(2023, 12, 1),
application_start_date=datetime(2023, 10, 16),
application_end_date=datetime(2023, 11, 15),
invitation_date=datetime(2023, 12, 1).date(),
application_start_date=datetime(2023, 10, 16).date(),
application_end_date=datetime(2023, 11, 15).date(),
)

def test_is_accepting_applications(self):
# Ensure that the types of fields are from django, not from when I created the object in memory
self.session.refresh_from_db()

with freeze_time("2023-10-15"):
self.assertFalse(self.session.is_accepting_applications())

Expand Down

0 comments on commit cb7f44d

Please sign in to comment.