Skip to content

Commit

Permalink
fix validation for missing key and update test
Browse files Browse the repository at this point in the history
  • Loading branch information
jupe committed Jun 17, 2020
1 parent b060777 commit 3c78c24
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lockable/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def read_resources_list(filename):

def validate_json(data):
counts = count_by(data, lambda obj: obj.get('id'))
no_ids = filter_(counts.keys(), lambda key: isinstance(counts[key], str))
no_ids = filter_(counts.keys(), lambda key: key is None)
if no_ids:
raise AssertionError('Invalid json, id property is missing')

Expand Down
2 changes: 1 addition & 1 deletion tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,6 @@ def test_duplicate_id_in_json(self):
validate_json(data)

def test_missing_id_in_json(self):
data = [{"a": "1234"}, {"id": "12345"}, {"id": "12345"}]
data = [{"a": "1234"}, {"id": "12345"}, {"id": "123456"}]
with self.assertRaises(AssertionError):
validate_json(data)

0 comments on commit 3c78c24

Please sign in to comment.