def test_process_json_valid_json(): user_value = '{"name": "foobar", "bla": ["a", 1, "b", false]}' assert process_json(user_value) == { "name": "foobar", "bla": ["a", 1, "b", False], }
def test_process_json_valid_json(): user_value = '{"name": "foobar", "bla": ["a", 1, "b", false]}' assert process_json(user_value) == { 'name': 'foobar', 'bla': ['a', 1, 'b', False], }
def test_process_json_deep_dict(): """Test `process_json` for correct output on JSON input. Test for dict in dict case. """ user_value = '''{ "key": "value", "integer_key": 37, "dict_key": { "deep_key": "deep_value", "deep_integer": 42, "deep_list": [ "deep value 1", "deep value 2", "deep value 3" ] }, "list_key": [ "value 1", "value 2", "value 3" ] }''' assert process_json(user_value) == { "key": "value", "integer_key": 37, "dict_key": { "deep_key": "deep_value", "deep_integer": 42, "deep_list": ["deep value 1", "deep value 2", "deep value 3"], }, "list_key": ["value 1", "value 2", "value 3"], }
def test_process_json_valid_json(): """Test `process_json` for correct output on JSON input. Test for simple dict with list. """ user_value = '{"name": "foobar", "bla": ["a", 1, "b", false]}' assert process_json(user_value) == { 'name': 'foobar', 'bla': ['a', 1, 'b', False], }
def test_process_json_deep_dict(): user_value = """{ "key": "value", "integer_key": 37, "dict_key": { "deep_key": "deep_value", "deep_integer": 42, "deep_list": [ "deep value 1", "deep value 2", "deep value 3" ] }, "list_key": [ "value 1", "value 2", "value 3" ] }""" assert process_json(user_value) == { "key": "value", "integer_key": 37, "dict_key": { "deep_key": "deep_value", "deep_integer": 42, "deep_list": [ "deep value 1", "deep value 2", "deep value 3", ], }, "list_key": [ "value 1", "value 2", "value 3", ], }
def test_process_json_deep_dict(): user_value = '''{ "key": "value", "integer_key": 37, "dict_key": { "deep_key": "deep_value", "deep_integer": 42, "deep_list": [ "deep value 1", "deep value 2", "deep value 3" ] }, "list_key": [ "value 1", "value 2", "value 3" ] }''' assert process_json(user_value) == { "key": "value", "integer_key": 37, "dict_key": { "deep_key": "deep_value", "deep_integer": 42, "deep_list": [ "deep value 1", "deep value 2", "deep value 3", ] }, "list_key": [ "value 1", "value 2", "value 3", ] }
def test_process_json_non_dict(): with pytest.raises(click.UsageError) as exc_info: process_json("[1, 2]") assert str(exc_info.value) == "Requires JSON dict."
def test_process_json_invalid_json(): with pytest.raises(click.UsageError) as exc_info: process_json("nope]") assert str(exc_info.value) == "Unable to decode to JSON."
def test_process_json_non_dict(): """Test `process_json` for correct error on non-JSON input.""" with pytest.raises(click.UsageError) as exc_info: process_json('[1, 2]') assert str(exc_info.value) == 'Requires JSON dict.'
def test_process_json_invalid_json(): """Test `process_json` for correct error on malformed input.""" with pytest.raises(click.UsageError) as exc_info: process_json('nope]') assert str(exc_info.value) == 'Unable to decode to JSON.'
def test_process_json_non_dict(): with pytest.raises(click.UsageError) as exc_info: process_json('[1, 2]') assert str(exc_info.value) == 'Requires JSON dict.'
def test_process_json_invalid_json(): with pytest.raises(click.UsageError) as exc_info: process_json('nope]') assert str(exc_info.value) == 'Unable to decode to JSON.'