Commit 3128de09 by Calen Pennington

Handle get_history methods which are generators (and thus don't raise…

Handle get_history methods which are generators (and thus don't raise DoesNotExist until the generator is started)
parent 0e70dad8
...@@ -362,7 +362,7 @@ class _UserStateClientTestHistory(_UserStateClientTestUtils): ...@@ -362,7 +362,7 @@ class _UserStateClientTestHistory(_UserStateClientTestUtils):
def test_empty_history(self): def test_empty_history(self):
with self.assertRaises(self.client.DoesNotExist): with self.assertRaises(self.client.DoesNotExist):
self.get_history(user=0, block=0) next(self.get_history(user=0, block=0))
def test_single_history(self): def test_single_history(self):
self.set(user=0, block=0, state={'a': 'b'}) self.set(user=0, block=0, state={'a': 'b'})
...@@ -651,7 +651,8 @@ class DictUserStateClient(XBlockUserStateClient): ...@@ -651,7 +651,8 @@ class DictUserStateClient(XBlockUserStateClient):
if (username, block_key, scope) not in self._history: if (username, block_key, scope) not in self._history:
raise self.DoesNotExist(username, block_key, scope) raise self.DoesNotExist(username, block_key, scope)
return iter(self._history[(username, block_key, scope)]) for entry in self._history[(username, block_key, scope)]:
yield entry
def iter_all_for_block(self, block_key, scope=Scope.user_state, batch_size=None): def iter_all_for_block(self, block_key, scope=Scope.user_state, batch_size=None):
""" """
......
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