Skip to content

Commit

Permalink
fix: remove ui hidden option and default value from kind attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-pinchelimouroux committed Oct 24, 2024
1 parent 80325ca commit 21d6dca
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
14 changes: 10 additions & 4 deletions tests/http_api/test_http_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,28 @@ def auth():

@pytest.fixture(scope="function")
def offset_pagination() -> OffsetLimitPaginationConfig:
return OffsetLimitPaginationConfig(offset_name="super_offset", limit_name="super_limit", limit=5)
return OffsetLimitPaginationConfig(
kind="OffsetLimitPaginationConfig", offset_name="super_offset", limit_name="super_limit", limit=5
)


@pytest.fixture(scope="function")
def page_pagination() -> PageBasedPaginationConfig:
return PageBasedPaginationConfig(page_name="my_page", per_page_name="my_per_page", per_page=2, page=1)
return PageBasedPaginationConfig(
kind="PageBasedPaginationConfig", page_name="my_page", per_page_name="my_per_page", per_page=2, page=1
)


@pytest.fixture(scope="function")
def cursor_pagination() -> CursorBasedPaginationConfig:
return CursorBasedPaginationConfig(cursor_name="my_cursor", cursor_filter=".metadata.next_cursor")
return CursorBasedPaginationConfig(
kind="CursorBasedPaginationConfig", cursor_name="my_cursor", cursor_filter=".metadata.next_cursor"
)


@pytest.fixture(scope="function")
def hyper_media_pagination() -> HyperMediaPaginationConfig:
return HyperMediaPaginationConfig(next_link_filter=".metadata.next_link")
return HyperMediaPaginationConfig(kind="HyperMediaPaginationConfig", next_link_filter=".metadata.next_link")


def test_transform_with_jq():
Expand Down
1 change: 0 additions & 1 deletion toucan_connectors/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ def transform_with_jq(data: object, jq_filter: str) -> list:
)

UI_HIDDEN: dict[str, Any] = {"ui.hidden": True}
UI_REQUIRED: dict[str, Any] = {"ui.required": True}


def get_loop():
Expand Down
10 changes: 5 additions & 5 deletions toucan_connectors/http_api/pagination_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from pydantic import BaseModel, Field

from toucan_connectors.common import UI_HIDDEN, UI_REQUIRED, FilterSchemaDescription
from toucan_connectors.common import UI_HIDDEN, FilterSchemaDescription
from toucan_connectors.http_api.http_api_data_souce import HttpAPIDataSource

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -52,7 +52,7 @@ def get_error_status_whitelist(self) -> list[str] | None:


class OffsetLimitPaginationConfig(PaginationConfig):
kind: Literal["OffsetLimitPaginationConfig"] = Field("OffsetLimitPaginationConfig", **UI_HIDDEN, **UI_REQUIRED)
kind: Literal["OffsetLimitPaginationConfig"]
offset_name: str = "offset"
offset: int = Field(0, **UI_HIDDEN)
limit_name: str = "limit"
Expand Down Expand Up @@ -82,7 +82,7 @@ def get_pagination_info_filter(self) -> str | None:


class PageBasedPaginationConfig(PaginationConfig):
kind: Literal["PageBasedPaginationConfig"] = Field("PageBasedPaginationConfig", **UI_HIDDEN, **UI_REQUIRED)
kind: Literal["PageBasedPaginationConfig"]
page_name: str = "page"
page: int = 0
per_page_name: str | None = None
Expand Down Expand Up @@ -129,7 +129,7 @@ def get_error_status_whitelist(self) -> list[int] | None:


class CursorBasedPaginationConfig(PaginationConfig):
kind: Literal["CursorBasedPaginationConfig"] = Field("CursorBasedPaginationConfig", **UI_HIDDEN, **UI_REQUIRED)
kind: Literal["CursorBasedPaginationConfig"]
cursor_name: str = "cursor"
cursor: str | None = Field(None, **UI_HIDDEN)
cursor_filter: str = Field(..., description=FilterSchemaDescription)
Expand Down Expand Up @@ -163,7 +163,7 @@ def get_error_status_whitelist(self) -> list[str] | None:


class HyperMediaPaginationConfig(PaginationConfig):
kind: Literal["HyperMediaPaginationConfig"] = Field("HyperMediaPaginationConfig", **UI_HIDDEN, **UI_REQUIRED)
kind: Literal["HyperMediaPaginationConfig"]
next_link_filter: str = Field(..., description=FilterSchemaDescription)
next_link: str | None = None

Expand Down

0 comments on commit 21d6dca

Please sign in to comment.