class ActivationKeyEditView(BaseLoggedInView): return_to_all = Text("//a[text()='Activation Keys']") action_list = SelectActionList() dialog = ConfirmationDialog() lce = LCESelector() @property def is_displayed(self): return self.browser.wait_for_element(self.return_to_all, exception=False) is not None
class ActivationKeyCreateView(BaseLoggedInView): name = TextInput(id='name') hosts_limit = LimitInput() description = TextInput(id='description') lce = LCESelector() content_view = Select(id='content_view_id') submit = Text("//button[contains(@ng-click, 'handleSave')]") @property def is_displayed(self): return self.browser.wait_for_element(self.name, exception=False) is not None
class ActivationKeyDetailsView(BaseLoggedInView): name = TextInput(id='name') description = TextInput(id='description') unlimited_hosts = Checkbox(name='limit') max_hosts = TextInput(id='max_hosts') submit = Text("//button[contains(@ng-click, 'handleSave')]") lce = LCESelector() content_view = Select(id='content_view_id') @property def is_displayed(self): return self.browser.wait_for_element(self.name, exception=False) is not None
class ActivationKeyEditView(BaseLoggedInView): return_to_all = Text("//a[text()='Activation Keys']") name = EditableEntry(name='Name') description = EditableEntry(name='Description') host_limit = EditableEntry(name='Host Limit') service_level = EditableEntrySelect(name='Service Level') action_list = SelectActionList() dialog = ConfirmationDialog() lce = LCESelector() @property def is_displayed(self): return self.browser.wait_for_element(self.return_to_all, exception=False) is not None @View.nested class subscriptions(SatTab): @View.nested class resources(AddRemoveResourcesView): checkbox_locator = ( './/table//tr[td[normalize-space(.)="%s"]]' '/following-sibling::tr//input[@type="checkbox"]')
class LCESelectorGroup(ParametrizedView): """Group of :class:`airgun.widgets.LCESelector`, typically present on page for selecting desired lifecycle environment. Usage:: lce = View.nested(LCESelectorGroup) #or @View.nested class lce(LCESelectorGroup): pass """ ROOT = (".//*[self::div or self::span][@path-selector='environments' or " "@path-selector='availableEnvironments']") PARAMETERS = ('lce_name', ) LAST_ENV = ".//div[contains(@class, 'path-selector')]/ul/li[last()]" lce = LCESelector(locator=ParametrizedLocator( "./div[contains(@class, 'path-selector')]/ul" "[li[normalize-space(.)='{lce_name}']]")) @classmethod def all(cls, browser): """Helper method which returns list of tuples with all LCESelector names (last available environment is used as a name). It's required for :meth:`read` to work properly. """ return [(element.text, ) for element in browser.elements(cls.LAST_ENV)] def fill(self, values=None): """Shortcut to pass the value to included ``lce`` :class:`airgun.widgets.LCESelector` widget. Usage remains the same as :class:`airgun.widgets.LCESelector` and :class:`widgetastic.widget.ParametrizedView` required param is filled automatically from passed lifecycle environment's name. Example:: my_view.lce.fill({'PROD': True}) Value ``True`` or ``False`` means to set corresponding checkbox value to the last checkbox available in widget (last lifecycle environment). If you want to select different lifecycle environment within the same route - pass its name as a value instead:: my_view.lce.fill({'PROD': 'Library'}) """ if values in (True, False): values = {self.context['lce_name']: values} else: values = {values: True} return self.lce.fill(values) def read(self): """Shortcut which returns value of included ``lce`` :class:`airgun.widgets.LCESelector` widget. Note that returned result will be wrapped in extra dict due to :class:`widgetastic.widget.ParametrizedView` nature:: { 'DEV': {'Library': False, 'DEV': True}, 'QA': {'Library': False, 'IT': True}, 'PROD': {'Library': False, 'PROD': True}, } """ return self.lce.read()