def test_create(app): app.auth.login_gr(login_sys="admin", pass_sys="secret") app.group.open_page_gr() app.group.create( add_new_group(n_name="date1", h_header="date2", f_footer="date3")) app.auth.logout_gr() time.sleep(1)
def test_new(app): app.auth.login(login_sys="admin", pass_sys="secret") app.group.open_page_address() app.group.create( add_new_group(n_name="date1", h_header="date2", f_footer="date3")) app.group.open_page_address() app.auth.logout() app.destroyer()
def get_group_list(self): if self.group_cache is None: wd = self.app.wd self.open_page_gr() 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(add_new_group(name=text, id=id)) return list(self.group_cache)
def test_edit_group(app, db): app.group.open_page_gr() old_groups = db.get_group_list() # index = randrange(len(old_groups)) group = add_new_group(name="sdf") group.id = old_groups[index].id if app.group.count() == 0: app.group.create( add_new_group(name="date1", header="date2", footer="date3")) app.group.open_page_gr() app.group.click_grIndex(index) app.group.edit_gr(group) app.group.open_page_gr() new_groups = db.get_group_list() # assert len(old_groups) == len(new_groups) # old_groups[index] = group assert sorted(old_groups, key=add_new_group.id_or_max) == sorted( new_groups, key=add_new_group.id_or_max)
def get_group_listt(self): list = [] cursor = self.connection.cursor() try: cursor.execute( "select group_id, group_name,group_header, group_footer from group_list" ) for row in cursor: (id, name, header, footer) = row list.append( add_new_group(id=str(id), name=name, header=header, footer=footer)) finally: cursor.close() return list
def test_delete_group(app, db, check_ui): app.group.open_page_gr() old_groups = db.get_group_list() # group = random.choice(old_groups) index = randrange(len(old_groups)) if app.group.count() == 0: app.group.create( add_new_group(name="date1", header="date2", footer="date3")) app.group.delete_gr_byId(group.id) app.group.open_page_gr() new_groups = db.get_group_list() # assert len(old_groups) - 1 == len(new_groups) # old_groups.remove(group) #old_groups[index:index+1]=[] assert old_groups == new_groups if check_ui: assert sorted(new_groups, key=add_new_group.id_or_max) == sorted( app.group.get_group_list(), key=add_new_group.id_or_max())
getopt.usage() sys.exit(2) n = 3 f = "data/groups.json" for o, a in opts: if 0 == "-n": n = int(a) elif o == "-f": f = a def random_string(prefix, maxlen): symbols = string.ascii_letters + string.digits + " " * 10 return prefix + "".join( [random.choice(symbols) for i in range(random.randrange(maxlen))]) testdata = [ add_new_group(name=random_string("name", 10), header=random_string("header", 15), footer=random_string("footer", 5)) 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(json.dumps(testdata, default=lambda x: x.__dict__, indent=2)) out.write(jsonpickle.encode(testdata))
def clean(group): return add_new_group(id=group.id, name=group.name.strip())
def convert(group): return add_new_group(id=str(group.id), name=group.name, header=group.header, footer=group.footer)