Commit bf074d47 by Ali Mohammad

Make the tests offset aware.

parent a5eaf4a6
...@@ -353,9 +353,9 @@ class _UserStateClientTestCRUD(_UserStateClientTestUtils): ...@@ -353,9 +353,9 @@ class _UserStateClientTestCRUD(_UserStateClientTestUtils):
self.assertItemsEqual(self.get_many(user=0, blocks=[0, 1]), []) self.assertItemsEqual(self.get_many(user=0, blocks=[0, 1]), [])
def test_get_mod_date(self): def test_get_mod_date(self):
start_time = datetime.now() start_time = datetime.utcnow()
self.set_many(user=0, block_to_state={0: {'a': 'b'}, 1: {'b': 'c'}}) self.set_many(user=0, block_to_state={0: {'a': 'b'}, 1: {'b': 'c'}})
end_time = datetime.now() end_time = datetime.utcnow()
mod_dates = self.get(user=0, block=0) mod_dates = self.get(user=0, block=0)
...@@ -364,15 +364,15 @@ class _UserStateClientTestCRUD(_UserStateClientTestUtils): ...@@ -364,15 +364,15 @@ class _UserStateClientTestCRUD(_UserStateClientTestUtils):
self.assertLess(mod_dates.updated, end_time) self.assertLess(mod_dates.updated, end_time)
def test_get_many_mod_date(self): def test_get_many_mod_date(self):
start_time = datetime.now() start_time = datetime.utcnow()
self.set_many( self.set_many(
user=0, user=0,
block_to_state={0: {'a': 'b'}}) block_to_state={0: {'a': 'b'}})
mid_time = datetime.now() mid_time = datetime.utcnow()
self.set_many( self.set_many(
user=0, user=0,
block_to_state={1: {'a': 'c'}}) block_to_state={1: {'a': 'c'}})
end_time = datetime.now() end_time = datetime.utcnow()
mod_dates = list(self.get_many( mod_dates = list(self.get_many(
user=0, user=0,
...@@ -621,7 +621,7 @@ class DictUserStateClient(XBlockUserStateClient): ...@@ -621,7 +621,7 @@ class DictUserStateClient(XBlockUserStateClient):
Add the specified state to the state history of this block. Add the specified state to the state history of this block.
""" """
history_list = self._history.setdefault((username, block_key, scope), []) history_list = self._history.setdefault((username, block_key, scope), [])
history_list.insert(0, XBlockUserState(username, block_key, state, datetime.now(), scope)) history_list.insert(0, XBlockUserState(username, block_key, state, datetime.utcnow(), scope))
def get_many(self, username, block_keys, scope=Scope.user_state, fields=None): def get_many(self, username, block_keys, scope=Scope.user_state, fields=None):
for key in block_keys: for key in block_keys:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment