From b699f0641ec4f3ee81b5cf18ecd510551c41f99f Mon Sep 17 00:00:00 2001 From: Peter Ondrejka Date: Mon, 4 Dec 2023 09:56:23 +0100 Subject: [PATCH] eol banner (#1049) (cherry picked from commit 75c465ef7f52067de4ebe8973014efcef3b725cd) --- airgun/entities/eol_banner.py | 32 ++++++++++++++++++++++++++++++++ airgun/session.py | 6 ++++++ airgun/views/eol_banner.py | 20 ++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 airgun/entities/eol_banner.py create mode 100644 airgun/views/eol_banner.py diff --git a/airgun/entities/eol_banner.py b/airgun/entities/eol_banner.py new file mode 100644 index 000000000..af23a09d7 --- /dev/null +++ b/airgun/entities/eol_banner.py @@ -0,0 +1,32 @@ +from airgun.entities.base import BaseEntity +from airgun.navigation import NavigateStep, navigator +from airgun.views.eol_banner import EOLBannerView + + +class EOLBannerEntity(BaseEntity): + def read(self): + view = self.navigate_to(self, 'NavigateToEOLBanner') + return view.read() + + def dismiss(self): + view = self.navigate_to(self, 'NavigateToEOLBanner') + view.dismiss_button.click() + + def is_warning(self): + view = self.navigate_to(self, 'NavigateToEOLBanner') + return view.warning + + def is_danger(self): + view = self.navigate_to(self, 'NavigateToEOLBanner') + return view.danger + + +@navigator.register(EOLBannerEntity) +class NavigateToEOLBanner(NavigateStep): + VIEW = EOLBannerView + + def step(self, *args, **kwargs): + self.view.wait_displayed() + + def am_i_here(self, *args, **kwargs): + return self.view.is_displayed diff --git a/airgun/session.py b/airgun/session.py index 969328166..930c81630 100644 --- a/airgun/session.py +++ b/airgun/session.py @@ -31,6 +31,7 @@ from airgun.entities.discoveredhosts import DiscoveredHostsEntity from airgun.entities.discoveryrule import DiscoveryRuleEntity from airgun.entities.domain import DomainEntity +from airgun.entities.eol_banner import EOLBannerEntity from airgun.entities.errata import ErrataEntity from airgun.entities.filter import FilterEntity from airgun.entities.hardware_model import HardwareModelEntity @@ -345,6 +346,11 @@ def bookmark(self): """Instance of Bookmark entity.""" return self._open(BookmarkEntity) + @cached_property + def eol_banner(self): + """Instance of Bookmark entity.""" + return self._open(EOLBannerEntity) + @cached_property def cloudinventory(self): """Instance of RH Cloud Inventory Upload entity.""" diff --git a/airgun/views/eol_banner.py b/airgun/views/eol_banner.py new file mode 100644 index 000000000..cd3933efb --- /dev/null +++ b/airgun/views/eol_banner.py @@ -0,0 +1,20 @@ +from widgetastic.widget import ClickableMixin, Text, View + + +class EOLBannerView(View, ClickableMixin): + name = Text('//div[@id="satellite-eol-banner"]') + dismiss_button = Text('//*[@id="satellite-oel-banner-dismiss-button"]') + + @property + def warning(self): + """Return whether the banner is displayed in warning style""" + return 'warning' in " ".join(self.browser.classes(self.name)) + + @property + def danger(self): + """Return whether the banner is displayed in danger style""" + return 'danger' in " ".join(self.browser.classes(self.name)) + + @property + def is_displayed(self): + return self.name.is_displayed