Skip to content

Commit

Permalink
tests - missing changes
Browse files Browse the repository at this point in the history
  • Loading branch information
commonism committed Oct 3, 2024
1 parent 5735051 commit 81fa10b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion tests/debug_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def debug_session_factory(*args, **kwargs) -> httpx.Client:
p = api._.find_pet_by_id(data={}, parameters={"id": 1})


@pytest.mark.asyncio
@pytest.mark.asyncio(loop_scope="session")
async def test_debug_log_async(httpx_mock, petstore_expanded):
httpx_mock.add_response(headers={"Content-Type": "application/json"}, json={"foo": 1})

Expand Down
23 changes: 12 additions & 11 deletions tests/schema_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,24 +369,24 @@ def test_schema_discriminated_union_invalid_array(with_schema_discriminated_unio
def test_schema_discriminated_union_warnings(with_schema_discriminated_union_warning, openapi_version):
from aiopenapi3.errors import DiscriminatorWarning

with pytest.warns(
DiscriminatorWarning, match=r"Discriminated Union member \S+ without const/enum key property \S+"
):
api = OpenAPI("/", with_schema_discriminated_union_warning)

with pytest.warns(
DiscriminatorWarning,
match=r"Discriminated Union member key property enum mismatches property mapping \S+ \!= \S+",
with (
pytest.warns(
DiscriminatorWarning,
match=r"Discriminated Union member key property enum mismatches property mapping \S+ \!= \S+",
),
pytest.warns(DiscriminatorWarning, match=r"Discriminated Union member \S+ without const/enum key property \S+"),
):
api = OpenAPI("/", with_schema_discriminated_union_warning)

if (openapi_version.major, openapi_version.minor, openapi_version.patch) >= (3, 1, 0):
s = copy.deepcopy(with_schema_discriminated_union_warning)
# del s["components"]["schemas"]["C"]["properties"]["object_type"]["enum"]
s["components"]["schemas"]["C"]["properties"]["object_type"]["const"] = "f"
del s["components"]["schemas"]["B"]["properties"]["object_type"]["enum"]
s["components"]["schemas"]["B"]["properties"]["object_type"]["enum"] = ["f"]
s["components"]["schemas"]["A"]["properties"]["object_type"]["enum"] = ["a"]
s["components"]["schemas"]["C"]["properties"]["object_type"]["const"] = "c"
with pytest.warns(
DiscriminatorWarning,
match=r"Discriminated Union member key property const mismatches property mapping \S+ \!= \S+",
match=r"Discriminated Union member key property enum mismatches property mapping \S+ \!= \S+",
):
api = OpenAPI("/", s)

Expand Down Expand Up @@ -493,6 +493,7 @@ def test_schema_enum_array(with_schema_enum_array):
api = OpenAPI("/", with_schema_enum_array)


@pytest.mark.httpx_mock(can_send_already_matched_responses=True)
def test_schema_pathitems(httpx_mock, with_schema_pathitems):
httpx_mock.add_response(headers={"Content-Type": "application/json"}, json={"foo": "bar"})
api = OpenAPI("/", with_schema_pathitems, session_factory=httpx.Client)
Expand Down

0 comments on commit 81fa10b

Please sign in to comment.