Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-ora2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-ora2
Commits
43e1fe82
Commit
43e1fe82
authored
Apr 07, 2014
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use UTC when finding the current time
parent
604b0849
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
apps/openassessment/xblock/openassessmentblock.py
+1
-1
apps/openassessment/xblock/test/test_openassessment.py
+18
-1
No files found.
apps/openassessment/xblock/openassessmentblock.py
View file @
43e1fe82
...
...
@@ -381,7 +381,7 @@ class OpenAssessmentBlock(
open_range
=
date_ranges
[
2
]
# Check if we are in the open date range
now
=
dt
.
datetime
.
now
()
.
replace
(
tzinfo
=
pytz
.
utc
)
now
=
dt
.
datetime
.
utc
now
()
.
replace
(
tzinfo
=
pytz
.
utc
)
if
now
<
open_range
[
0
]:
return
True
,
"start"
,
open_range
[
0
],
open_range
[
1
]
...
...
apps/openassessment/xblock/test/test_openassessment.py
View file @
43e1fe82
...
...
@@ -396,6 +396,23 @@ class TestDates(XBlockHandlerTestCase):
)
@scenario
(
'data/basic_scenario.xml'
)
def
test_is_closed_uses_utc
(
self
,
xblock
):
# No dates are set in the basic scenario
# so we can safely set the release date to one minute in the past (in UTC)
xblock
.
start
=
dt
.
datetime
.
utcnow
()
.
replace
(
tzinfo
=
pytz
.
utc
)
-
dt
.
timedelta
(
minutes
=
1
)
# Since the start date is in the past, the problem should be available
is_closed
,
__
,
__
,
__
=
xblock
.
is_closed
()
self
.
assertFalse
(
is_closed
)
# Set the start date one hour in the future (in UTC)
xblock
.
start
=
dt
.
datetime
.
utcnow
()
.
replace
(
tzinfo
=
pytz
.
utc
)
+
dt
.
timedelta
(
hours
=
1
)
# Now the problem should be open
is_closed
,
__
,
__
,
__
=
xblock
.
is_closed
()
self
.
assertTrue
(
is_closed
)
@scenario
(
'data/basic_scenario.xml'
)
def
test_is_released_unpublished
(
self
,
xblock
):
# Simulate the runtime published_date mixin field
# The scenario doesn't provide a start date, so `is_released()`
...
...
@@ -444,7 +461,7 @@ class TestDates(XBlockHandlerTestCase):
datetime_patcher
=
patch
.
object
(
openassessmentblock
,
'dt'
,
Mock
(
wraps
=
dt
))
mocked_datetime
=
datetime_patcher
.
start
()
self
.
addCleanup
(
datetime_patcher
.
stop
)
mocked_datetime
.
datetime
.
now
.
return_value
=
now
mocked_datetime
.
datetime
.
utc
now
.
return_value
=
now
is_closed
,
reason
,
start
,
due
=
xblock
.
is_closed
(
step
=
step
)
self
.
assertEqual
(
is_closed
,
expected_is_closed
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment