From ad7058631ffe32c90cc6173a5df3ff0ecbb21f8b Mon Sep 17 00:00:00 2001 From: saravanan palanisamy Date: Sat, 17 Oct 2020 20:47:15 +0400 Subject: [PATCH] add test cases for expect_alt --- tests/test_tolerance.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/test_tolerance.py b/tests/test_tolerance.py index 22c0183..d0f00c7 100644 --- a/tests/test_tolerance.py +++ b/tests/test_tolerance.py @@ -139,6 +139,18 @@ def test_tolerance_jsonpath_must_match_expected_value(): } ) is True + t = { + "type": "jsonpath", + "path": "$.foo[?(@.baz)].baz", + "expect": [["hello", "bonjour"]], + "expect_alt": [["hello", "joe"]] + } + ensure_hypothesis_tolerance_is_valid(t) + assert within_tolerance( + t, value={ + 'foo': {"baz": ["hello", "joe"]} + } + ) is True t = { "type": "jsonpath", @@ -152,6 +164,19 @@ def test_tolerance_jsonpath_must_match_expected_value(): } ) is True + t = { + "type": "jsonpath", + "path": "$.foo[?(@.baz)].baz", + "expect": [[["hello"], ["bonjour"]]], + "expect_alt": [[["hello"], ["joe"]]] + } + ensure_hypothesis_tolerance_is_valid(t) + assert within_tolerance( + t, value={ + 'foo': {"baz": [["hello"], ["joe"]]} + } + ) is True + t = { "type": "jsonpath", "path": "$.foo[?(@.baz)].baz", @@ -201,7 +226,7 @@ def test_tolerance_jsonpath_must_match_expected_values(): assert within_tolerance( t, value={ 'foo': [{"baz": "hello"}, {"baz": "bonjour"}] - }, + }, ) is True