def test_match_unknown_kwarg(self): with pytest.raises(ValueError) as error: payloads_match_exactly( '{"1": ["one", "two"]}', '{"1": ["two", "one"]}', foo="bar" ) assert "parameter(s) are not valid" in str(error.value)
def test_match_too_few_args(self): with pytest.raises(TypeError) as error: payloads_match_exactly('{"1": "one"}') assert ( "payloads_match_exactly() missing 1 required positional argument: 'json_2'" in str(error.value) )
def test_match_identical_objects_fail_02(self): t1 = '{"1": "one"}' t2 = '{"1": "one", "2": "two"}' with pytest.raises(JsonCompareError) as error: payloads_match_exactly(t1, t2) assert "Payloads do NOT match!" in str(error.value)
def test_match_ignore_order_not_boolean(self): with pytest.raises(ValueError) as error: payloads_match_exactly( '{"1": ["one", "two"]}', '{"1": ["two", "one"]}', "/foo" ) assert ( "Argument `ignore_order` must eval to boolean. Valid values: ${TRUE} or ${FALSE}" in str(error.value) )
def test_match_too_many_args(self): with pytest.raises(TypeError) as error: payloads_match_exactly( '{"1": ["one", "two"]}', '{"1": ["two", "one"]}', False, "/foo" ) assert ( "payloads_match_exactly() takes from 2 to 3 positional arguments but 4 were given" in str(error.value) )
def test_match_invalid_arguments(self, t1, t2, exp_result): with pytest.raises(JsonCompareError) as error: payloads_match_exactly(t1, t2) assert exp_result in str(error.value)
def test_match_identical_objects(self): t1 = '{"1": "one"}' t2 = '{"1": "one"}' assert payloads_match_exactly(t1, t2) == True