예제 #1
0
    def test_regex_no_match_header(self):
        response = FakeResponse("abchelloabc")

        with pytest.raises(exceptions.RegexAccessError):
            validate_regex(response,
                           "(?P<greeting>hola)",
                           header="test_header")
예제 #2
0
    def test_regex_match_header(self):
        response = FakeResponse("abchelloabc")

        matched = validate_regex(response, "(?P<greeting>hello)",
                                 "test_header")

        assert "greeting" in matched["regex"]
예제 #3
0
    def test_in_jmespath(self, match):
        response = FakeResponse(
            json.dumps({
                "path1": "val1",
                "path2": ["val2"],
                "path3": {
                    "sub": "val3"
                }
            }))

        expression, path, expected = match

        result = validate_regex(response, expression, in_jmespath=path)

        assert result["regex"]["num"] == expected[-1]
예제 #4
0
    def test_regex_no_match_header(self):
        response = FakeResponse("abchelloabc")

        with pytest.raises(AssertionError):
            validate_regex(response, "(?P<greeting>hola)", "test_header")