Skip to content

Commit

Permalink
Add AK update host limit entity (#1744)
Browse files Browse the repository at this point in the history
* Add AK update host limit entity

* Update the entity
  • Loading branch information
LadislavVasina1 authored Feb 20, 2025
1 parent d1b2604 commit 955087f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
26 changes: 26 additions & 0 deletions airgun/entities/activationkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,32 @@ def update(self, entity_name, values):
view.flash.dismiss()
return filled_values

def update_ak_host_limit(self, entity_name, host_limit):
"""
Update activation key host limit
args:
entity_name: Activation key name
host_limit: Host limit for activation key. Can be either string 'unlimited' or an integer
raises:
ValueError: If host limit is not string 'unlimited' or an integer
"""

if isinstance(host_limit, (str)):
host_limit = host_limit.lower()
# Check that host limit is string 'unlimited' or integer
if (host_limit != 'unlimited') and (not isinstance(host_limit, (int))):
raise ValueError("Host limit must be either string 'unlimited' or an integer")

view = self.navigate_to(self, 'Edit', entity_name=entity_name)
view.wait_displayed()
self.browser.plugin.ensure_page_safe()
view.details.host_limit_edit_btn.click()
view.details.unlimited_content_host_checkbox.fill(host_limit == 'unlimited')
if host_limit != 'unlimited':
view.details.host_limit_input.fill(host_limit)
view.details.host_limit_save_btn.click()

def add_subscription(self, entity_name, subscription_name):
"""Add subscription to activation key
Expand Down
14 changes: 14 additions & 0 deletions airgun/views/activationkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ class details(SatTab):
name = EditableEntry(name='Name')
description = EditableEntry(name='Description')
hosts_limit = EditableLimitEntry(name='Host Limit')
host_limit_edit_btn = Text(
locator='//dd[@bst-edit-custom="activationKey.max_hosts"]//div[@ng-click="edit()"]'
)
unlimited_content_host_checkbox = Checkbox(
locator='//input[@ng-model="activationKey.unlimited_hosts"]'
)
host_limit_input = TextInput(locator='//input[@ng-model="activationKey.max_hosts"]')
host_limit_save_btn = Text(
locator='//dd[contains(@bst-edit-custom, "activationKey.max_hosts")]//button[@ng-click="save()"]'
)
host_limit_cancel_btn = Text(
locator='//dd[contains(@bst-edit-custom, "activationKey.max_hosts")]//button[@ng-click="cancel()"]'
)

service_level = EditableEntrySelect(name='Service Level')
lce = ParametrizedView.nested(LCESelectorGroup)
content_view = EditableEntrySelect(name='Content View')
Expand Down

0 comments on commit 955087f

Please sign in to comment.