Skip to content

Commit

Permalink
Update get_register_command to reflect new mandatory fields (#1087) (#…
Browse files Browse the repository at this point in the history
…1094)

Signed-off-by: Gaurav Talreja <[email protected]>
(cherry picked from commit 064530e)

Co-authored-by: Gaurav Talreja <[email protected]>
  • Loading branch information
Satellite-QE and Gauravtalreja1 authored Dec 19, 2023
1 parent 7563221 commit f45bb26
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
16 changes: 11 additions & 5 deletions airgun/entities/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,19 @@ def create(self, values):
host_view.flash.assert_no_error()
host_view.flash.dismiss()

def get_register_command(self, values, full_read=None):
def get_register_command(self, values=None, full_read=None):
"""Get curl command generated on Register Host page"""
view = self.navigate_to(self, 'Register')
view.fill(values)
self.browser.click(view.generate_command)
self.browser.plugin.ensure_page_safe()
view.registration_command.wait_displayed()
if values is not None:
view.fill(values)
if view.general.activation_keys.read():
self.browser.click(view.generate_command)
self.browser.plugin.ensure_page_safe()
view.registration_command.wait_displayed()
else:
view.general.new_activation_key_link.wait_displayed()
if view.generate_command.disabled:
raise DisabledWidgetError('Generate registration command button is disabled')
if full_read:
return view.read()
return view.registration_command.read()
Expand Down
10 changes: 3 additions & 7 deletions airgun/views/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ class additional_information(SatTab):


class HostRegisterView(BaseLoggedInView):
title = Text("//h1[normalize-space(.)='Register Host']")
generate_command = PF4Button('registration_generate_btn')
cancel = PF4Button('registration-cancel-button')
registration_command = TextInput(locator="//input[@aria-label='Copyable input']")
Expand All @@ -519,6 +520,7 @@ class general(Tab):
insecure = Checkbox(id='reg_insecure')
activation_keys = BaseMultiSelect('activation-keys-field')
activation_key_helper = Text("//div[@id='activation_keys_field-helper']")
new_activation_key_link = Link('//a[normalize-space(.)="Create new activation key"]')

@View.nested
class advanced(Tab):
Expand All @@ -544,7 +546,7 @@ class advanced(Tab):

@property
def is_displayed(self):
return self.browser.wait_for_element(self.general.operating_system, exception=False)
return self.browser.wait_for_element(self.title, exception=False)

def before_fill(self, values):
"""Fill some of the parameters in the widgets with values.
Expand All @@ -566,12 +568,6 @@ def before_fill(self, values):
logger=self.logger,
)
self.general.__getattribute__(field).fill(field_value)
wait_for(
lambda: self.general.linux_host_init_link.is_displayed,
timeout=30,
delay=2,
logger=self.logger,
)


class RecommendationWidget(GenericLocatorWidget):
Expand Down

0 comments on commit f45bb26

Please sign in to comment.