Skip to content
Snippets Groups Projects
Commit a8d6443d authored by Awais Jibran's avatar Awais Jibran
Browse files

Do not update correctmap if state is invaid.

parent a590d89f
No related branches found
No related tags found
No related merge requests found
...@@ -91,8 +91,11 @@ class CorrectMap(object): ...@@ -91,8 +91,11 @@ class CorrectMap(object):
# empty current dict # empty current dict
self.__init__() self.__init__()
if not correct_map:
return
# create new dict entries # create new dict entries
if correct_map and not isinstance(correct_map.values()[0], dict): if not isinstance(correct_map.values()[0], dict):
# special migration # special migration
for k in correct_map: for k in correct_map:
self.set(k, correctness=correct_map[k]) self.set(k, correctness=correct_map[k])
......
...@@ -215,3 +215,13 @@ class CorrectMapTest(unittest.TestCase): ...@@ -215,3 +215,13 @@ class CorrectMapTest(unittest.TestCase):
for invalid in invalid_list: for invalid in invalid_list:
with self.assertRaises(Exception): with self.assertRaises(Exception):
self.cmap.update(invalid) self.cmap.update(invalid)
def test_set_none_state(self):
"""
Test that if an invalid state is set to correct map, the state does not
update at all.
"""
invalid_list = [None, "", False, 0]
for invalid in invalid_list:
self.cmap.set_dict(invalid)
self.assertEqual(self.cmap.get_dict(), {})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment