Skip to content

Commit

Permalink
extra - use *args
Browse files Browse the repository at this point in the history
  • Loading branch information
commonism committed Oct 17, 2023
1 parent 9409125 commit 86f75e1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions aiopenapi3/extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ class Reduce(Document, Init):

def __init__(
self,
operations: List[
*operations: List[
Union[Tuple[Union[re.Pattern, str], Optional[List[Union[re.Pattern, str]]]], Union[re.Pattern, str]]
],
) -> None:
assert isinstance(operations, list), type(operations)
assert isinstance(operations, (list, tuple)), type(operations)
self.operations = operations
super().__init__()

Expand Down
27 changes: 15 additions & 12 deletions tests/extra_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import re
import typing

if sys.version_info >= (3, 9):
from pathlib import Path
Expand All @@ -11,24 +12,26 @@

from aiopenapi3 import OpenAPI
from aiopenapi3.loader import FileSystemLoader
from aiopenapi3.extra import Cull, Init, Reduce, Document

from aiopenapi3.extra import Cull, Reduce
from typing import Dict

if typing.TYPE_CHECKING:
from aiopenapi3.plugin import Document


class PetStoreReduced(Reduce):
def __init__(self):
super().__init__({"/user/{username}": None})
super().__init__(("/user/{username}", None))


class MSGraph:
def __init__(self):
super().__init__(
operations=[
("/me/profile", None),
(re.compile(r"/me/sendMail.*"), None),
"accessReviewDecisions.accessReviewDecision.ListAccessReviewDecision",
re.compile(r"drives.drive.items.driveItem.permissions.permission*"),
]
("/me/profile", None),
(re.compile(r"/me/sendMail.*"), None),
"accessReviewDecisions.accessReviewDecision.ListAccessReviewDecision",
re.compile(r"drives.drive.items.driveItem.permissions.permission*"),
)

@staticmethod
Expand Down Expand Up @@ -128,7 +131,7 @@ def test_reduced(with_extra_reduced, httpx_mock, compressor):
"http://127.0.0.1/api.yaml",
with_extra_reduced,
session_factory=httpx.Client,
plugins=[compressor([("/A/{Path}", None)])],
plugins=[compressor(("/A/{Path}", None))],
loader=FileSystemLoader(Path("tests/fixtures")),
)

Expand Down Expand Up @@ -157,7 +160,7 @@ def test_reduced(with_extra_reduced, httpx_mock, compressor):
"http://127.0.0.1/api.yaml",
with_extra_reduced,
session_factory=httpx.Client,
plugins=[compressor([(re.compile("/B"), None)])],
plugins=[compressor((re.compile("/B"), None))],
loader=FileSystemLoader(Path("tests/fixtures")),
)
assert "/A/{Path}" not in api.paths.paths
Expand All @@ -171,7 +174,7 @@ def test_reduced(with_extra_reduced, httpx_mock, compressor):
"http://127.0.0.1/api.yaml",
with_extra_reduced,
session_factory=httpx.Client,
plugins=[compressor(["A"])],
plugins=[compressor("A")],
loader=FileSystemLoader(Path("tests/fixtures")),
)
assert "/A/{Path}" in api.paths.paths
Expand All @@ -189,7 +192,7 @@ def test_reduced(with_extra_reduced, httpx_mock, compressor):
"http://127.0.0.1/api.yaml",
with_extra_reduced,
session_factory=httpx.Client,
plugins=[compressor([re.compile(r"[A]{1}$")])],
plugins=[compressor(re.compile(r"[A]{1}$"))],
loader=FileSystemLoader(Path("tests/fixtures")),
)
assert "/A/{Path}" in api.paths.paths
Expand Down

0 comments on commit 86f75e1

Please sign in to comment.