Skip to content

Commit

Permalink
Fixed Type checking issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Temidayo32 committed Dec 13, 2024
1 parent 277b2ef commit 7c6eb3f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
15 changes: 9 additions & 6 deletions foxpuppet/windows/browser/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
from foxpuppet.windows.browser.navbar import NavBar
from foxpuppet.windows.browser.notifications import BaseNotification
from selenium.webdriver.remote.webelement import WebElement
from typing import Any, Optional, Union
from typing import Any, Optional, Union, TypeVar, Type

T = TypeVar("T", bound="BaseNotification")


class BrowserWindow(BaseWindow):
Expand Down Expand Up @@ -66,8 +68,9 @@ def notification(self) -> BaseNotification | Any:
return None # no notification is displayed

def wait_for_notification(
self, notification_class: Optional[type["BaseNotification"]] = BaseNotification
) -> BaseNotification | Any:
self,
notification_class: Optional[Type[T]] = BaseNotification, # type: ignore
) -> Optional[T]:
"""Wait for the specified notification to be displayed.
Args:
Expand All @@ -77,7 +80,7 @@ def wait_for_notification(
`BaseNotification`.
Returns:
:py:class:`BaseNotification`: Firefox notification.
Optional[:py:class:`BaseNotification`]: Firefox notification or None.
"""
if notification_class:
Expand All @@ -89,13 +92,13 @@ def wait_for_notification(
lambda _: isinstance(self.notification, notification_class),
message=message,
)
return self.notification
return self.notification # type: ignore
else:
self.wait.until(
lambda _: self.notification is None,
message="Unexpected notification shown.",
)
return None
return None

@property
def is_private(self) -> bool | Any:
Expand Down
13 changes: 7 additions & 6 deletions tests/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def addon() -> AddOn:
@pytest.fixture
def progress_notification(
addon: AddOn, browser: BrowserWindow, webserver: WebServer, selenium: WebDriver
) -> AddOnProgress:
) -> AddOnProgress | None:
"""Fixture that triggers the download progress notification.
Returns:
Expand All @@ -91,7 +91,7 @@ def progress_notification(
@pytest.fixture
def blocked_notification(
addon: AddOn, browser: BrowserWindow, webserver: WebServer, selenium: WebDriver
) -> AddOnInstallBlocked:
) -> AddOnInstallBlocked | None:
"""Fixture causing a blocked notification to appear in Firefox.
Returns:
Expand All @@ -106,7 +106,7 @@ def blocked_notification(
@pytest.fixture
def confirmation_notification(
browser: BrowserWindow, blocked_notification: AddOnInstallBlocked
) -> AddOnInstallConfirmation:
) -> AddOnInstallConfirmation | None:
"""Fixture that allows an add-on to be installed.
Returns:
Expand All @@ -120,7 +120,7 @@ def confirmation_notification(
@pytest.fixture
def complete_notification(
browser: BrowserWindow, confirmation_notification: AddOnInstallConfirmation
) -> AddOnInstallComplete:
) -> AddOnInstallComplete | None:
"""Fixture that installs an add-on.
Returns:
Expand All @@ -134,7 +134,7 @@ def complete_notification(
@pytest.fixture
def failed_notification(
addon: AddOn, browser: BrowserWindow, webserver: WebServer, selenium: WebDriver
) -> AddOnInstallFailed:
) -> AddOnInstallFailed | None:
"""Fixture that triggers a failed installation notification.
Returns:
Expand Down Expand Up @@ -248,6 +248,7 @@ def test_close_failed_notification(
failed_notification.close()
browser.wait_for_notification(None)


@pytest.mark.parametrize(
"firefox_options", [{"page_load_strategy_none": True}], indirect=True
)
Expand All @@ -256,4 +257,4 @@ def test_progress_notification_downloading(
) -> None:
"""Verify downloading status is reported correctly."""
description = progress_notification.is_downloading
assert description is not None
assert description is True

0 comments on commit 7c6eb3f

Please sign in to comment.