From 955087f3f4d99080f306f2fab5453b10e2007782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20Va=C5=A1ina?= Date: Thu, 20 Feb 2025 08:27:54 +0100 Subject: [PATCH] Add AK update host limit entity (#1744) * Add AK update host limit entity * Update the entity --- airgun/entities/activationkey.py | 26 ++++++++++++++++++++++++++ airgun/views/activationkey.py | 14 ++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/airgun/entities/activationkey.py b/airgun/entities/activationkey.py index d6c889a32..c4feb3526 100644 --- a/airgun/entities/activationkey.py +++ b/airgun/entities/activationkey.py @@ -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 diff --git a/airgun/views/activationkey.py b/airgun/views/activationkey.py index 0ed632dbc..746d31163 100644 --- a/airgun/views/activationkey.py +++ b/airgun/views/activationkey.py @@ -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')