|
1 | 1 | import pytest
|
2 | 2 |
|
3 | 3 | from openapi_core.schema.operations.exceptions import InvalidOperation
|
| 4 | +from openapi_core.schema.paths.exceptions import InvalidPath |
4 | 5 | from openapi_core.shortcuts import create_spec
|
5 | 6 | from openapi_core.validation.request.validators import RequestValidator
|
6 | 7 | from openapi_core.wrappers.mock import MockRequest
|
@@ -39,11 +40,26 @@ def test_invalid_operation(self, factory, server, spec_path):
|
39 | 40 | spec_dict = factory.spec_from_file(spec_path)
|
40 | 41 | spec = create_spec(spec_dict)
|
41 | 42 | validator = RequestValidator(spec)
|
42 |
| - request = MockRequest(server, "get", "/nonexistent") |
| 43 | + request = MockRequest(server, "post", "/status") |
43 | 44 |
|
44 | 45 | result = validator.validate(request)
|
45 | 46 |
|
46 | 47 | assert len(result.errors) == 1
|
47 | 48 | assert isinstance(result.errors[0], InvalidOperation)
|
48 | 49 | assert result.body is None
|
49 | 50 | assert result.parameters == {}
|
| 51 | + |
| 52 | + @pytest.mark.parametrize("server", servers) |
| 53 | + @pytest.mark.parametrize("spec_path", spec_paths) |
| 54 | + def test_invalid_path(self, factory, server, spec_path): |
| 55 | + spec_dict = factory.spec_from_file(spec_path) |
| 56 | + spec = create_spec(spec_dict) |
| 57 | + validator = RequestValidator(spec) |
| 58 | + request = MockRequest(server, "get", "/nonexistent") |
| 59 | + |
| 60 | + result = validator.validate(request) |
| 61 | + |
| 62 | + assert len(result.errors) == 1 |
| 63 | + assert isinstance(result.errors[0], InvalidPath) |
| 64 | + assert result.body is None |
| 65 | + assert result.parameters == {} |
0 commit comments