Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AK update host limit entity #1744

Merged
merged 2 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()"]'
)
Comment on lines +88 to +97

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also modify host limit on the new AK page. Would it be appropriate to add support for that here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that new PR would be more appropriate for it


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