Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-user-state-client
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-user-state-client
Commits
0393a23c
Commit
0393a23c
authored
Jul 30, 2015
by
Ali Mohammad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TIMEZONES
parent
bf074d47
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
7 deletions
+8
-7
edx_user_state_client/interface.py
+1
-1
edx_user_state_client/tests.py
+7
-6
No files found.
edx_user_state_client/interface.py
View file @
0393a23c
...
...
@@ -34,7 +34,7 @@ class XBlockUserState(namedtuple('_XBlockUserState', ['username', 'block_key', '
state: A dict mapping field names to the values of those fields for this XBlock.
updated: A :class:`datetime.datetime`. We guarantee that the fields
that were returned in "state" have not been changed since
this time.
this time
(in UTC)
.
scope: A :class:`xblock.fields.Scope` identifying which XBlock scope this state is coming from.
"""
__slots__
=
()
...
...
edx_user_state_client/tests.py
View file @
0393a23c
...
...
@@ -17,6 +17,7 @@ test suite, use the snippet:
from
datetime
import
datetime
from
unittest
import
TestCase
import
pytz
from
contracts
import
contract
from
edx_user_state_client.interface
import
XBlockUserStateClient
,
XBlockUserState
...
...
@@ -353,9 +354,9 @@ class _UserStateClientTestCRUD(_UserStateClientTestUtils):
self
.
assertItemsEqual
(
self
.
get_many
(
user
=
0
,
blocks
=
[
0
,
1
]),
[])
def
test_get_mod_date
(
self
):
start_time
=
datetime
.
utcnow
(
)
start_time
=
datetime
.
now
(
pytz
.
utc
)
self
.
set_many
(
user
=
0
,
block_to_state
=
{
0
:
{
'a'
:
'b'
},
1
:
{
'b'
:
'c'
}})
end_time
=
datetime
.
utcnow
(
)
end_time
=
datetime
.
now
(
pytz
.
utc
)
mod_dates
=
self
.
get
(
user
=
0
,
block
=
0
)
...
...
@@ -364,15 +365,15 @@ class _UserStateClientTestCRUD(_UserStateClientTestUtils):
self
.
assertLess
(
mod_dates
.
updated
,
end_time
)
def
test_get_many_mod_date
(
self
):
start_time
=
datetime
.
utcnow
(
)
start_time
=
datetime
.
now
(
pytz
.
utc
)
self
.
set_many
(
user
=
0
,
block_to_state
=
{
0
:
{
'a'
:
'b'
}})
mid_time
=
datetime
.
utcnow
(
)
mid_time
=
datetime
.
now
(
pytz
.
utc
)
self
.
set_many
(
user
=
0
,
block_to_state
=
{
1
:
{
'a'
:
'c'
}})
end_time
=
datetime
.
utcnow
(
)
end_time
=
datetime
.
now
(
pytz
.
utc
)
mod_dates
=
list
(
self
.
get_many
(
user
=
0
,
...
...
@@ -621,7 +622,7 @@ class DictUserStateClient(XBlockUserStateClient):
Add the specified state to the state history of this block.
"""
history_list
=
self
.
_history
.
setdefault
((
username
,
block_key
,
scope
),
[])
history_list
.
insert
(
0
,
XBlockUserState
(
username
,
block_key
,
state
,
datetime
.
utcnow
(
),
scope
))
history_list
.
insert
(
0
,
XBlockUserState
(
username
,
block_key
,
state
,
datetime
.
now
(
pytz
.
utc
),
scope
))
def
get_many
(
self
,
username
,
block_keys
,
scope
=
Scope
.
user_state
,
fields
=
None
):
for
key
in
block_keys
:
...
...
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