Skip to content

Commit 26d2333

Browse files
committed
Rename within_deadline to submission_open; add submission_closed
1 parent 454c264 commit 26d2333

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

examples/5_import_funcs/test_clock.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from jmu_pytest_utils.common import assert_pep8, assert_docs
2-
from jmu_pytest_utils.common import within_deadline, postpone_tests
2+
from jmu_pytest_utils.common import submission_open, postpone_tests
33
from jmu_pytest_utils.decorators import weight
44

55
from clock import time_str, add_time
@@ -42,5 +42,5 @@ def test_add_time_hard():
4242
assert add_time(1, 15, 2*24*60 + 75) == "02:30 AM", "2 days and 75 minutes after 01:15 AM"
4343

4444

45-
if within_deadline():
45+
if submission_open():
4646
postpone_tests()

jmu_pytest_utils/common.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,13 @@ def run_module(filename, input=None):
135135
return run_command(["python", filename], input)
136136

137137

138-
def within_deadline(before=5, after=5):
138+
def submission_open(before=5, after=5):
139139
"""Check if the current time is within the user's submission window.
140140
141-
The window is extended `before` minutes prior to the release date
142-
and `after` minutes beyond the due date (or late due date, if set).
141+
The window starts at the release date and ends at the due date (or late
142+
due date, if set). This function applies a tolerance by including times:
143+
* `before` minutes prior to the release date
144+
* `after` minutes beyond the due/late date
143145
144146
Args:
145147
before (int): Minutes to extend the window before the release date.
@@ -156,7 +158,7 @@ def within_deadline(before=5, after=5):
156158
except FileNotFoundError:
157159
return False
158160

159-
# Get the user's assignment dates
161+
# Get the assignment's dates specific to the user
160162
assignment = metadata["users"][0]["assignment"]
161163
beg = datetime.fromisoformat(assignment["release_date"])
162164
end = datetime.fromisoformat(assignment["due_date"])
@@ -173,6 +175,14 @@ def within_deadline(before=5, after=5):
173175
return beg <= now <= end
174176

175177

178+
def submission_closed():
179+
"""Check if the current time is outside the user's submission window.
180+
181+
See submission_open() for more details. This function returns the opposite.
182+
"""
183+
return not submission_open()
184+
185+
176186
def postpone_tests(
177187
title="Ready to grade",
178188
message="Your submission has been received and will be graded manually.",

0 commit comments

Comments
 (0)