chore: import upstream snapshot with attribution
Backend release / release (push) Waiting to run
Bandit Security Scan / bandit_scan (push) Waiting to run
Build and push multi-arch DocsGPT Docker image / build (linux/amd64, ubuntu-latest, amd64) (push) Waiting to run
Build and push multi-arch DocsGPT Docker image / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Waiting to run
Build and push multi-arch DocsGPT Docker image / manifest (push) Blocked by required conditions
Build and push DocsGPT FE Docker image for development / build (linux/amd64, ubuntu-latest, amd64) (push) Waiting to run
Build and push DocsGPT FE Docker image for development / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Waiting to run
Build and push DocsGPT FE Docker image for development / manifest (push) Blocked by required conditions
Python linting / ruff (push) Waiting to run
Run python tests with pytest / Run tests and count coverage (3.12) (push) Waiting to run
React Widget Build / build (push) Waiting to run
Backend release / release (push) Waiting to run
Bandit Security Scan / bandit_scan (push) Waiting to run
Build and push multi-arch DocsGPT Docker image / build (linux/amd64, ubuntu-latest, amd64) (push) Waiting to run
Build and push multi-arch DocsGPT Docker image / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Waiting to run
Build and push multi-arch DocsGPT Docker image / manifest (push) Blocked by required conditions
Build and push DocsGPT FE Docker image for development / build (linux/amd64, ubuntu-latest, amd64) (push) Waiting to run
Build and push DocsGPT FE Docker image for development / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Waiting to run
Build and push DocsGPT FE Docker image for development / manifest (push) Blocked by required conditions
Python linting / ruff (push) Waiting to run
Run python tests with pytest / Run tests and count coverage (3.12) (push) Waiting to run
React Widget Build / build (push) Waiting to run
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import pytest
|
||||
from application.parser.file.openapi3_parser import OpenAPI3Parser
|
||||
from openapi_parser import parse
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"urls, expected_base_urls",
|
||||
[
|
||||
(
|
||||
[
|
||||
"http://petstore.swagger.io/v1",
|
||||
"https://api.example.com/v1/resource",
|
||||
"https://api.example.com/v1/another/resource",
|
||||
"https://api.example.com/v1/some/endpoint",
|
||||
],
|
||||
["http://petstore.swagger.io", "https://api.example.com"],
|
||||
),
|
||||
],
|
||||
)
|
||||
@pytest.mark.unit
|
||||
def test_get_base_urls(urls, expected_base_urls):
|
||||
assert OpenAPI3Parser().get_base_urls(urls) == expected_base_urls
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_get_info_from_paths():
|
||||
file_path = "tests/test_openapi3.yaml"
|
||||
data = parse(file_path)
|
||||
path = data.paths[1]
|
||||
assert (
|
||||
OpenAPI3Parser().get_info_from_paths(path)
|
||||
== "\nget=Expected response to a valid request"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_parse_file():
|
||||
file_path = "tests/test_openapi3.yaml"
|
||||
results_expected = (
|
||||
"Base URL:http://petstore.swagger.io,https://api.example.com\nPath1: "
|
||||
+ "/pets\ndescription: None\nparameters: []\nmethods: \n"
|
||||
+ "get=A paged array of pets\npost=Null "
|
||||
+ "response\nPath2: /pets/{petId}\ndescription: None\n"
|
||||
+ "parameters: []\nmethods: "
|
||||
+ "\nget=Expected response to a valid request\n"
|
||||
)
|
||||
openapi_parser_test = OpenAPI3Parser()
|
||||
results = openapi_parser_test.parse_file(file_path)
|
||||
assert results == results_expected
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main()
|
||||
Reference in New Issue
Block a user