def test_basic_fillable(): class MyFillable(Fillable): def as_fill_value(self): return 'foo' x = MyFillable() assert Fillable.coerce(x) == 'foo' assert Fillable.coerce(123) == 123
def copy_to(self, domain, new_name=None, replace=None, cancel=False): copy_page = navigate_to(self, 'Copy') fill_values = {'override_existing': replace, 'new_name': new_name} if domain is not None: d = Fillable.coerce(domain) if copy_page.to_domain_text.is_displayed: if copy_page.to_domain_text.text != d: raise ValueError('Wanted to select {} but the only domain possible is {}' .format(copy_page.to_domain_text.text, d)) else: fill_values['to_domain_select'] = d copy_page.fill(fill_values) if not cancel: copy_page.copy_button.click() # Attention! Now we should be on a different page but the flash message is the same! copy_page.flash.assert_no_error() copy_page.flash.assert_message('Copy selected Automate {} was saved' .format(self.__class__)) else: copy_page.cancel_button.click() # Attention! Now we should be on a different page but the flash message is the same! copy_page.flash.assert_no_error() copy_page.flash.assert_message('Copy Automate {} was cancelled by the user' .format(self.__class__))
def set_order(self, items): if not isinstance(items, (list, tuple)): items = [items] processed_items = [Fillable.coerce(item) for item in items] priority_page = navigate_to(self, 'Priority') changed = priority_page.domains.fill(processed_items) if changed: # Changed priority_page.save_button.click() else: # Not changed priority_page.cancel_button.click() domains_view = self.create_view(DomainListView) assert domains_view.is_displayed domains_view.flash.assert_no_error() if changed: domains_view.flash.assert_message('Priority Order was saved') else: domains_view.flash.assert_message('Edit of Priority Order was cancelled by the user') return changed
def wrapped(self, value, *args, **kwargs): return method(self, Fillable.coerce(value), *args, **kwargs)