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
Branches
Tags release-2020-07-02-00.53
No related merge requests found
......@@ -91,8 +91,11 @@ class CorrectMap(object):
# empty current dict
self.__init__()
if not correct_map:
return
# 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
for k in correct_map:
self.set(k, correctness=correct_map[k])
......
......@@ -215,3 +215,13 @@ class CorrectMapTest(unittest.TestCase):
for invalid in invalid_list:
with self.assertRaises(Exception):
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% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment