Skip to content

Commit

Permalink
format and fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
BilalG1 committed Jan 17, 2025
1 parent edb034e commit fc88281
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
6 changes: 3 additions & 3 deletions core/test/parser/test_type_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def assert_is_iso_format(date_string):
)
def test_pydantic_type_date_validate_type_success(date_string):
parsed_date = ParserTypeDate.validate_type(date_string)
assert isinstance(
parsed_date, str
), f"Expected string for '{date_string}', got {parsed_date}"
assert isinstance(parsed_date, str), (
f"Expected string for '{date_string}', got {parsed_date}"
)
assert_is_iso_format(parsed_date)


Expand Down
2 changes: 1 addition & 1 deletion sdk/harambe/contrib/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async def wait_for_selector(self, selector: str, **kwargs: Any) -> None:

class ResponseWithStatus(Protocol):
"""Protocol for goto responses across all harnesses. Use minimal attributes required for current use cases."""

status: int
headers: dict[str, str]

Expand Down
4 changes: 3 additions & 1 deletion sdk/harambe/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,9 @@ async def run(
harness: WebHarness = playwright_harness,
evaluator: Optional[ExpressionEvaluator] = None,
observer: Optional[OutputObserver | List[OutputObserver]] = None,
goto_error_handler: Callable[[str, int, dict[str, str]], Awaitable[None]] = default_error_callback,
goto_error_handler: Callable[
[str, int, dict[str, str]], Awaitable[None]
] = default_error_callback,
**harness_options: Unpack[HarnessOptions],
) -> "SDK":
"""
Expand Down
14 changes: 7 additions & 7 deletions sdk/test/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,12 @@ async def scraper(sdk: SDK, *args, **kwargs):

assert observer.data[0]["page_content"] == observer.data[1]["table_content"]
for text in ["Apple", "Orange", "Banana"]:
assert (
text in observer.data[0]["page_content"]
), f"{text} not in {observer.data[0]['page_content']}"
assert (
text in observer.data[1]["table_content"]
), f"{text} not in {observer.data[1]['table_content']}"
assert text in observer.data[0]["page_content"], (
f"{text} not in {observer.data[0]['page_content']}"
)
assert text in observer.data[1]["table_content"], (
f"{text} not in {observer.data[1]['table_content']}"
)


@pytest.mark.parametrize("harness", [soup_harness])
Expand Down Expand Up @@ -698,7 +698,7 @@ async def custom_error_handler(url, status_code):
schema={},
context={"status": "Open"},
observer=observer,
goto_err_handler=error_callback,
goto_error_handler=error_callback,
)

# Ensure data is saved when error is handled (either with custom or no callback)
Expand Down
18 changes: 9 additions & 9 deletions sdk/test/test_stealth.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ async def test_navigator_webdriver(async_page):
@pytest.mark.asyncio
async def test_user_agent(async_page):
user_agent = await async_page.evaluate("navigator.userAgent")
assert (
"headless" not in user_agent.lower()
), "User agent should not contain 'headless'"
assert "headless" not in user_agent.lower(), (
"User agent should not contain 'headless'"
)


@pytest.mark.asyncio
Expand All @@ -56,9 +56,9 @@ async def test_plugins(async_page):
@pytest.mark.asyncio
async def test_app_version(async_page):
app_version = await async_page.evaluate("navigator.appVersion")
assert (
"headless" not in app_version.lower()
), "App version should not contain 'headless'"
assert "headless" not in app_version.lower(), (
"App version should not contain 'headless'"
)


@pytest.mark.asyncio
Expand Down Expand Up @@ -88,6 +88,6 @@ async def test_connection_rtt(async_page):
}
""")

assert (
connection_rtt is not None and connection_rtt != 0
), "Connection RTT should exist and not be zero in non-headless browsers"
assert connection_rtt is not None and connection_rtt != 0, (
"Connection RTT should exist and not be zero in non-headless browsers"
)

0 comments on commit fc88281

Please sign in to comment.