Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test day check #184

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions rp_yal/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@ def test_get_ordered_content_set_weekend(self, mock_search_ocs):
self.assertIsNone(contentset_id)
mock_search_ocs.assert_not_called()

@freeze_time("2024-05-05 01:30:00")
@patch("rp_yal.utils.search_ordered_content_sets")
@patch("rp_yal.utils.get_first_matching_content_set")
def test_get_ordered_content_set_weekend_and_override(
self, mock_first_mcs, mock_search_ocs
):
"""
On the weekend we can override to Monday using the test_day field.
"""
mock_search_ocs.return_value = TEST_CONTENT_SETS
mock_first_mcs.return_value = 1

fields = {"test_day": 1}
contentset_id = utils.get_ordered_content_set(self.org, fields)

self.assertEqual(contentset_id, 1)
mock_search_ocs.assert_called_with(self.org, "low lit")
mock_first_mcs.assert_called_with(TEST_CONTENT_SETS, fields)

@freeze_time("2024-05-06 01:30:00")
@patch("rp_yal.utils.search_ordered_content_sets")
@patch("rp_yal.utils.get_first_matching_content_set")
Expand Down
6 changes: 6 additions & 0 deletions rp_yal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ def get_ordered_content_set(org, fields):

weekday = datetime.today().weekday()

if fields.get("test_day"):
try:
weekday = int(fields.get("test_day")) - 1
except ValueError:
pass

if weekday == 0:
# Monday
if "low" in fields.get("sexual_health_lit_risk", ""):
Expand Down
Loading