Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sambible committed Oct 9, 2023
1 parent bc9d0a4 commit ce63985
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 73 deletions.
68 changes: 0 additions & 68 deletions airgun/views/common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import time
from widgetastic.widget import (
Checkbox,
ConditionalSwitchableView,
Expand All @@ -13,8 +12,6 @@
from widgetastic_patternfly import BreadCrumb, Button, Tab, TabWithDropdown
from widgetastic_patternfly4.navigation import Navigation
from widgetastic_patternfly4.ouia import Dropdown
from widgetastic_patternfly4.ouia import PatternflyTable
from widgetastic_patternfly4.ouia import Button as PF4Button

from airgun.utils import get_widget_by_name, normalize_dict_values
from airgun.widgets import (
Expand Down Expand Up @@ -386,71 +383,6 @@ class add_tab(AddTab):
)


class NewAddRemoveResourcesView(View):
searchbox = PF4Search()
type = Dropdown(
locator='.//div[contains(@class, "All repositories") or'
' contains(@aria-haspopup="listbox")]'
)
Status = Dropdown(
locator='.//div[contains(@class, "All") or contains(@aria-haspopup="listbox")]'
)
add_repo = PF4Button('OUIA-Generated-Button-secondary-2')
# Need to add kebab menu
table = PatternflyTable(
component_id='OUIA-Generated-Table-4',
column_widgets={
0: Checkbox(locator='.//input[@type="checkbox"]'),
'Type': Text('.//a'),
'Name': Text('.//a'),
'Product': Text('.//a'),
'Sync State': Text('.//a'),
'Content': Text('.//a'),
'Status': Text('.//a'),
},
)

def search(self, value):
"""Search for specific available resource and return the results"""
self.searchbox.search(value)
# Tried following ways to wait for table to be displayed, only sleep worked
# Might need a before/after fill
wait_for(
lambda: self.table.is_displayed is True,
timeout=60,
delay=1,
)
time.sleep(3)
self.table.wait_displayed()
return self.table.read()

def add(self, value):
"""Associate specific resource"""
self.search(value)
next(self.table.rows())[0].widget.fill(True)
self.add_repo.click()

def fill(self, values):
"""Associate resource(s)"""
if not isinstance(values, list):
values = list((values,))
for value in values:
self.add(value)

def remove(self, value):
"""Unassign some resource(s).
:param str or list values: string containing resource name or a list of
such strings.
"""
self.search(value)
next(self.table.rows())[0].widget.fill(True)
self.remove_button.click()

def read(self):
"""Read all table values from both resource tables"""
return self.table.read()


class TemplateEditor(View):
"""Default view for template entity editor that can be present for example
on provisioning template of partition table pages. It contains from
Expand Down
70 changes: 65 additions & 5 deletions airgun/views/contentview_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

from airgun.views.common import (
BaseLoggedInView,
NewAddRemoveResourcesView,
SearchableViewMixinPF4,
)
from airgun.widgets import (
Expand All @@ -26,6 +25,67 @@

LOCATION_NUM = 3

class NewAddRemoveResourcesView(View):
searchbox = PF4Search()
type = Dropdown(
locator='.//div[contains(@class, "All repositories") or'
' contains(@aria-haspopup="listbox")]'
)
Status = Dropdown(
locator='.//div[contains(@class, "All") or contains(@aria-haspopup="listbox")]'
)
add_repo = PF4Button('OUIA-Generated-Button-secondary-2')
# Need to add kebab menu
table = PatternflyTable(
component_id='OUIA-Generated-Table-4',
column_widgets={
0: Checkbox(locator='.//input[@type="checkbox"]'),
'Type': Text('.//a'),
'Name': Text('.//a'),
'Product': Text('.//a'),
'Sync State': Text('.//a'),
'Content': Text('.//a'),
'Status': Text('.//a'),
},
)

def search(self, value):
"""Search for specific available resource and return the results"""
self.searchbox.search(value)
wait_for(
lambda: self.table.is_displayed is True,
timeout=60,
delay=1,
)
self.table.wait_displayed()
return self.table.read()

def add(self, value):
"""Associate specific resource"""
self.search(value)
next(self.table.rows())[0].widget.fill(True)
self.add_repo.click()

def fill(self, values):
"""Associate resource(s)"""
if not isinstance(values, list):
values = list((values,))
for value in values:
self.add(value)

def remove(self, value):
"""Unassign some resource(s).
:param str or list values: string containing resource name or a list of
such strings.
"""
self.search(value)
next(self.table.rows())[0].widget.fill(True)
self.remove_button.click()

def read(self):
"""Read all table values from both resource tables"""
return self.table.read()


class ContentViewTableView(BaseLoggedInView, SearchableViewMixinPF4):
title = Text('.//h1[@data-ouia-component-id="cvPageHeaderText"]')
Expand Down Expand Up @@ -83,12 +143,10 @@ def after_fill(self, value):
class ContentViewEditView(BaseLoggedInView):
breadcrumb = BreadCrumb('breadcrumbs-list')
search = PF4Search()
title = Text("//h2[contains(., 'Publish) or contains(@id, 'pf-wizard-title-0')]")
actions = ActionsDropdown(
"//div[contains(@data-ouia-component-id, 'OUIA-Generated-Dropdown-2')]"
".//button[contains(@id, 'toggle-dropdown')]"
)
publish = PF4Button('cv-details-publish-button')
# not sure if this is needed
dialog = ConfirmationDialog()

@property
Expand Down Expand Up @@ -128,7 +186,7 @@ class versions(Tab):

def search(self, version_name):
"""Searches for content view version.
Searchbox can't search by version name, only by id, that's why in
Searchbox can't search by version name, only by number, that's why in
case version name was passed, it's transformed into recognizable
value before filling, for example::
'Version 1.0' -> 'version = 1'
Expand Down Expand Up @@ -210,3 +268,5 @@ def is_displayed(self):
and self.breadcrumb.locations[0] == 'Content Views'
and self.breadcrumb.locations[2] == 'Versions'
)


0 comments on commit ce63985

Please sign in to comment.