Ejemplo n.º 1
0
 def test_parseJSON(self) -> None:
     self.assertEqual("{}", normalize_flat_json("{}"))
     self.assertEqual('{"foo": "HELLO"}', normalize_flat_json('{"foo": "hello"}'))
     self.assertEqual(
         '{"bar": "123", "foo": "HELLO"}',
         normalize_flat_json('{"foo": "hello", "bar": "123"}'),
     )
     self.assertEqual(
         '{"bar": "123", "foo": "HELLO"}',
         normalize_flat_json('{"bar": "123", "foo": "hello"}'),
     )
     self.assertEqual(
         '{"foo": "A &&&"}', normalize_flat_json('{"foo": "a    &&& "}')
     )
Ejemplo n.º 2
0
 def test_parseJSON_Malformed(self) -> None:
     with pytest.raises(TypeError):
         normalize_flat_json(None)  # type: ignore[arg-type]
     with pytest.raises(TypeError):
         normalize_flat_json({"foo": "bar"})  # type: ignore[arg-type]
     with pytest.raises(JSONDecodeError):
         normalize_flat_json("")
     with pytest.raises(JSONDecodeError):
         normalize_flat_json("{")
Ejemplo n.º 3
0
 def test_parseJSON_NotFlatStringJSON(self) -> None:
     with pytest.raises(ValueError):
         normalize_flat_json('{"foo": "hello", "bar": 123}')
     with pytest.raises(ValueError):
         normalize_flat_json('{"foo": "hello", "bar": []]}')
     with pytest.raises(ValueError):
         normalize_flat_json('[{"foo": "hello"}]')