Exemplo n.º 1
0
    def test_saved_value_in_validate(self, nested_response, nested_schema,
                                     includes):
        r = RestResponse(Mock(), "Test 1", nested_schema, includes)

        class FakeResponse:
            headers = nested_response["headers"]
            content = "test".encode("utf8")
            def json(self):
                return nested_response["body"]
            status_code = nested_response["status_code"]

        r.verify(FakeResponse())
Exemplo n.º 2
0
    def test_validate_single_value_response(self, example_response, includes,
                                            value):
        """Check validating single value response (string, int, etc)."""
        del example_response['body']

        r = RestResponse(Mock(), "Test 1", example_response, includes)

        class FakeResponse:
            headers = example_response["headers"]
            content = "test".encode("utf8")
            def json(self):
                return value
            status_code = example_response["status_code"]

        r.verify(FakeResponse())
Exemplo n.º 3
0
    def test_incorrect_status_code(self, example_response, includes):
        """Test full verification + return saved values
        """
        r = RestResponse(Mock(), "Test 1", example_response, includes)

        class FakeResponse:
            headers = example_response["headers"]
            content = "test".encode("utf8")
            def json(self):
                return example_response["body"]
            status_code = 400

        with pytest.raises(exceptions.TestFailError):
            r.verify(FakeResponse())

        assert r.errors
Exemplo n.º 4
0
    def test_validate_and_save(self, example_response, includes):
        """Test full verification + return saved values
        """
        example_response["save"] = {"body": {"test_code": "code"}}
        r = RestResponse(Mock(), "Test 1", example_response, includes)

        class FakeResponse:
            headers = example_response["headers"]
            content = "test".encode("utf8")
            def json(self):
                return example_response["body"]
            status_code = example_response["status_code"]

        saved = r.verify(FakeResponse())

        assert saved == {"test_code": example_response["body"]["code"]}