Esempio n. 1
0
    def expect_json_property_value(self, json_property_path, expected_value):
        """Add an expectation that the HTTP response will be JSON and contain a
        property (found by traversing json_property_path) with the
        specified value.

        """
        self.add_expectation(
            ExpectedJsonEquality(json_property_path, expected_value))
        return self
Esempio n. 2
0
def test_json_equality_fails():
    validation = HttpValidation.get("url")
    exp = ExpectedJsonEquality("path", 5)
    with pytest.raises(ValidationFailure):
        exp.validate_value(validation, 5, 6)
Esempio n. 3
0
def test_json_wildcard_equality():
    validation = HttpValidation.get("url")
    exp = ExpectedJsonEquality("path[*]", [1, 2, 3])
    exp.validate_value(validation, 2, [1, 2, 3])
Esempio n. 4
0
def test_json_equality():
    validation = HttpValidation.get("url")
    exp = ExpectedJsonEquality("path", 5)
    exp.validate_value(validation, 5, 5)
Esempio n. 5
0
def test_validate_bad_json():
    resp = MockResponse({"path": {"no": {"value": 1}}, "distractor": "value"})
    validation = HttpValidation.get("url")
    exp = ExpectedJsonEquality("path.to.value", 4)
    with pytest.raises(ValidationFailure):
        exp.validate(validation, resp)
Esempio n. 6
0
def test_validate():
    resp = MockResponse({"path": {"to": {"value": 1}}, "distractor": "value"})
    validation = HttpValidation.get("url")
    exp = ExpectedJsonEquality("path.to.value", 1)
    exp.validate(validation, resp)
def test_json_equality_fails():
    validation = HttpValidation.get("url")
    exp = ExpectedJsonEquality("path", 5)
    with pytest.raises(ValidationFailure):
        exp.validate_value(validation, 5, 6)
def test_json_wildcard_equality():
    validation = HttpValidation.get("url")
    exp = ExpectedJsonEquality("path[*]", [1, 2, 3])
    exp.validate_value(validation, 2, [1, 2, 3])
def test_json_equality():
    validation = HttpValidation.get("url")
    exp = ExpectedJsonEquality("path", 5)
    exp.validate_value(validation, 5, 5)
def test_validate_bad_json():
    resp = MockResponse({"path": {"no": {"value": 1}}, "distractor": "value"})
    validation = HttpValidation.get("url")
    exp = ExpectedJsonEquality("path.to.value", 4)
    with pytest.raises(ValidationFailure):
        exp.validate(validation, resp)
def test_validate():
    resp = MockResponse({"path": {"to": {"value": 1}}, "distractor": "value"})
    validation = HttpValidation.get("url")
    exp = ExpectedJsonEquality("path.to.value", 1)
    exp.validate(validation, resp)