def test_modefi_some_groupe(app,db,check_ui): success = True group = Groupe(name="efsef", header="sfd", footer="adwd") if db.get_group_list() == 0: app.group.create(group) old_groups = db.get_group_list() old_group = random.choice(old_groups) group.id = old_group.id app.group.modefi_groupe_by_id(old_group.id, group) new_groups = db.get_group_list() old_groups.remove(old_group) old_groups.append(group) assert sorted(old_groups, key=Groupe.id_or_max) == sorted(new_groups, key=Groupe.id_or_max) if check_ui: assert sorted(new_groups, key=Groupe.id_or_max) == sorted(app.group.get_group_list(), key=Groupe.id_or_max)
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(Groupe(name=text, id=id)) return list(self.group_cache)
def test_delete_some_groupe_01(app,db,check_ui): success = True if db.get_group_list() == 0: app.group.create(Groupe(name="group2", header="group2", footer="group2")) old_groups = db.get_group_list() group = random.choice(old_groups) app.group.delete_groupe_by_id(group.id) assert len(old_groups) - 1 == app.group.count() new_groups = db.get_group_list() old_groups.remove(group) assert old_groups == new_groups if check_ui: assert sorted(new_groups, key=Groupe.id_or_max) == sorted(app.group.get_group_list(), key=Groupe.id_or_max)
def test_add_contact_to_group(app, db, orm): if len(db.get_group_list()) == 0: app.group.create(Groupe(name="n1", header="h1", footer="f1")) groups = db.get_group_list() group = random.choice(groups) contacts = orm.get_contacts_not_in_group(group) if len(contacts) == 0: app.contacts.newcontact( Contactfilld(firstname="Mia", middlename="Rk", lastname="Rose", nickename="Rose", title="Rosw comp", company="Rose", address="ertyui", homephone="1234", mobilephone="5678", workphone="90123", fax="4567", email1="*****@*****.**", email2="*****@*****.**", email3="*****@*****.**", homepage="ya.ry", selectbday="3", selectbmonthe="4", byear="1989", selectaday="8", selectamothe="12", ayear="2000", address2="dferesdfe", secondaryphone="rererr", notes="fgwewerewrw")) contacts = orm.get_contacts_not_in_group(group) contact = random.choice(contacts) app.contacts.add_contact_to_group(contact, group) contacts_in_group = orm.get_contacts_in_group(group) assert contact in contacts_in_group, "Contact id=%s не добавлен id=%s" % ( contact.id, group.id)
def clean(group): return Groupe(id=group.id, name=group.name.strip())
except getopt.GetoptError as err: getopt.usage() sys.exit(2) n = 5 f = "data/groups.json" for o, a in opts: if o == "-n": n = int(a) elif o == "-f": f = a def random_string(prefix, maxlen): symbol = string.ascii_letters + string.digits + " " * 10 return prefix + "".join( [random.choice(symbol) for i in range(random.randrange(maxlen))]) testdata = [Groupe(name="", header="", footer="")] + [ Groupe(name=random_string("name", 10), header=random_string("header", 20), footer=random_string("footer", 20)) 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(testdata))
from model.groupe import Groupe testdata = [ Groupe(name="n1", header="h1", footer="f3"), Groupe(name="n2", header="h2", footer="f2") ]
from fixture.orm import ORMFixture from model.groupe import Groupe db = ORMFixture(host="127.0.0.1", name="addressbook", user="******", password="") try: l = db.get_contacts_not_in_group(Groupe(id="3")) for item in l: print(item) print(len(l)) finally: pass # db.destroy()