Skip to content

Commit

Permalink
refactor: Restructuring of the client finished, while keeping the old…
Browse files Browse the repository at this point in the history
… client available for the first release.

All tests are passing and all adjustments in the tests were either for better readability or when accessing private members of the old class or setting attributes manually. All public methods should still work like they did before. Documentation, mypy and pylint fixes will follow in the next commits
  • Loading branch information
micha91 committed Jun 9, 2024
1 parent 9e809ec commit df565a1
Show file tree
Hide file tree
Showing 17 changed files with 2,079 additions and 1,701 deletions.
69 changes: 31 additions & 38 deletions open_api_client_build/build_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,65 +55,58 @@ def fix_spec(src: str, path: str | os.PathLike):
"you have to provide a file or url keyword as 1st arg."
)
spec_paths = spec["paths"]
if (
octet_schema := spec_paths.get(
"/projects/{projectId}/testruns/{testRunId}/actions/importXUnitTestResults",
{},
)
.get("post", {})
.get("requestBody", {})
.get("content", {})
.get("application/octet-stream", {})
.get("schema")
if octet_schema := spec_paths._get_multi(
"/projects/{projectId}/testruns/{testRunId}/actions/importXUnitTestResults",
{},
page_size=100,
page_number=1,
):
if octet_schema.get("type") == "object":
if (
octet_schema._get_multi("type", page_size=100, page_number=1)
== "object"
):
octet_schema["type"] = "string"
octet_schema["format"] = "binary"

for spec_path in spec_paths.values():
for operation_description in spec_path.values():
if responses := operation_description.get("responses"):
if responses := operation_description._get_multi(
"responses", page_size=100, page_number=1
):
if "4XX-5XX" in responses:
for code, resp in responses.items():
if error_code_pattern.fullmatch(code):
resp["content"] = responses["4XX-5XX"]["content"]
del responses["4XX-5XX"]

schemas = spec["components"]["schemas"]
if (
downloads := schemas.get("jobsSingleGetResponse", {})
.get("properties", {})
.get("data", {})
.get("properties", {})
.get("links", {})
.get("properties", {})
.get("downloads")
if downloads := schemas._get_multi(
"jobsSingleGetResponse", {}, page_size=100, page_number=1
):
if "items" not in downloads and downloads.get("type") == "array":
if (
"items" not in downloads
and downloads._get_multi("type", page_size=100, page_number=1)
== "array"
):
downloads["items"] = {"type": "string"}

if (
downloads := schemas.get("jobsSinglePostResponse", {})
.get("properties", {})
.get("data", {})
.get("properties", {})
.get("links", {})
.get("properties", {})
.get("downloads")
if downloads := schemas._get_multi(
"jobsSinglePostResponse", {}, page_size=100, page_number=1
):
if "items" not in downloads and downloads.get("type") == "array":
if (
"items" not in downloads
and downloads._get_multi("type", page_size=100, page_number=1)
== "array"
):
downloads["items"] = {"type": "string"}

if (
error_source := schemas.get("errors", {})
.get("properties", {})
.get("errors", {})
.get("items", {})
.get("properties", {})
.get("source")
if error_source := schemas._get_multi(
"errors", {}, page_size=100, page_number=1
):
error_source["nullable"] = True
if resource := error_source.get("properties", {}).get("resource"):
if resource := error_source._get_multi(
"properties", {}, page_size=100, page_number=1
)._get_multi("resource", page_size=100, page_number=1):
resource["nullable"] = True

with tempfile.NamedTemporaryFile("w", delete=False) as f:
Expand Down
2 changes: 1 addition & 1 deletion polarion_rest_api_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
__version__ = "0.0.0+unknown"
del metadata

from polarion_rest_api_client.client import OpenAPIPolarionProjectClient
from polarion_rest_api_client.data_models import (
SelectTestCasesBy,
TestRecord,
Expand All @@ -26,3 +25,4 @@
PolarionApiUnexpectedException,
PolarionWorkItemException,
)
from polarion_rest_api_client.old_client import OpenAPIPolarionProjectClient
88 changes: 0 additions & 88 deletions polarion_rest_api_client/base_client.py

This file was deleted.

Loading

0 comments on commit df565a1

Please sign in to comment.