Fix exception raised for certain non-JSON strings given to is_json

This is breaking pushes in production for certain manifests

Fixes https://jira.prod.coreos.systems/browse/QS-60
This commit is contained in:
Joseph Schorr 2017-11-14 13:40:11 -05:00
parent 5e5142a4d1
commit 2677720577
3 changed files with 40 additions and 2 deletions

View file

@ -0,0 +1,17 @@
import pytest
from util.validation import is_json
@pytest.mark.parametrize('string_value,expected', [
('{}', True),
('[]', True),
('[hello world]', False),
('{hello world}', False),
('[test] this is a test', False),
('hello world', False),
('{"hi": "there"}', True),
('[1, 2, 3, 4]', True),
('[1, 2, {"num": 3}, 4]', True),
])
def test_is_json(string_value, expected):
assert is_json(string_value) == expected