def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_group_page() self.group_cache = [] for element in wd.find_elements_by_css_selector('span.group'): text = element.text id = element.find_element_by_name('selected[]').get_attribute( 'value') self.group_cache.append(Group(group_name=text, id=id)) return list(self.group_cache)
def test_edit_group(app): """Validation of correct edit group (all field updated)""" app.group.validation_of_group_exist() old_groups = app.group.get_group_list() index = randrange(len(old_groups)) group = Group(group_name=Profinity.long_word_20, group_header=Profinity.long_word_20, group_footer=Profinity.long_word_20) group.id = old_groups[index].id app.group.edit_group_by_index(group, index) assert len(old_groups) == app.group.count(), 'Group list changed' new_groups = app.group.get_group_list() app.group.delete_first_group() old_groups[index] = group assert sorted(old_groups, key=Group.if_or_max) == sorted( new_groups, key=Group.if_or_max), 'Group list is different'
from fixture.TestBase import random_string from tests_group.group_helper import Group constant = [ Group(group_name='name1', group_header='header1', group_footer='footer1'), Group(group_name='name1', group_header='header1', group_footer='footer1') ] test_data = [ Group(group_name=name, group_header=header, group_footer=footer) for name in ['', random_string('name', 10)] for header in ['', random_string('header', 20)] for footer in ['', random_string('footer', 20)] ]
sys.exit(2) n = 5 f = 'data/groups.json' for o, a in opts: if o == "-n": n = int(a) elif o == "-f": f = str(a) '''def random_string(prefix, maxlen): symbols = string.ascii_letters + string.digits + ' ' #+ string.punctuation return prefix + ''.join([random.choice(symbols) for i in range(random.randrange(maxlen))])''' ''' test_data = [ Group(group_name=name, group_header=header, group_footer=footer) for name in ['', random_string('name', 10)] for header in ['', random_string('header', 20)] for footer in ['', random_string('footer', 20)]]''' test_data = [Group(group_name='', group_header='', group_footer='')] + [ Group(group_name=random_string('name', 10), group_header=random_string('header', 10), group_footer=random_string('footer', 10)) for i in range(n) ] file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", f) with open(file, 'w') as out: jsonpickle.set_encoder_options("json", indent=2) out.write(jsonpickle.encode(test_data))
def validation_of_group_exist(self): if self.count() == 0: self.create(Group(group_name='test')) self.click_group_page()