Skip to content

Commit

Permalink
Improved test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
niconoe committed Nov 21, 2024
1 parent 19f0f77 commit 09fc56d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 0 additions & 1 deletion dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,6 @@ def set_or_migrate_initial_data_import(

@staticmethod
def date_older_than_user_delay(user: WebsiteUser, the_date) -> bool:
# TODO: test this logic !!
today = timezone.now().date()

return the_date < (
Expand Down
16 changes: 16 additions & 0 deletions dashboard/tests/models/test_observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def setUp(self):
first_name="John",
last_name="Frusciante",
email="[email protected]",
notification_delay_days=365, # 1 year, the default value
)

# comment_author has also an alert that match second_obs
Expand Down Expand Up @@ -210,6 +211,21 @@ def test_mark_as_unseen_by_failure_3(self):
observation=self.obs, user=self.comment_author
)

def test_date_older_than_user_delay(self):
"""The method works as expected"""
yesterday = datetime.date.today() - datetime.timedelta(days=1)

self.assertFalse(
self.obs.date_older_than_user_delay(self.comment_author, the_date=yesterday)
)

two_years_ago = datetime.date.today() - datetime.timedelta(days=365 * 2)
self.assertTrue(
self.obs.date_older_than_user_delay(
self.comment_author, the_date=two_years_ago
)
)

def test_replace_observation(self):
"""High-level test: after creating a new observation with the same stable_id, make sure we can migrate the
linked entities then and then delete the initial observation"""
Expand Down

0 comments on commit 09fc56d

Please sign in to comment.