Пример #1
0
def test_edit_first_contact(app, db, check_ui):
    if len(db.get_contact_list()) == 0:
        app.contact.create(Contact("TIMMY"), Date("20", "March", "1990"),
                           Date("20", "June", "2000"))
    old_contacts = db.get_contact_list()
    contact = random.choice(old_contacts)
    index = old_contacts.index(contact)
    new_value_contact = Contact(id=contact.id,
                                firstname="xxx",
                                lastname="xxx",
                                nickname="xxx",
                                title="RxxxAZ",
                                company="xxx",
                                email="*****@*****.**")
    app.contact.edit_contact_by_id(contact.id, new_value_contact,
                                   Date("1", "March", "1880"),
                                   Date("2", "March", "2333"))
    new_contacts = db.get_contact_list()
    old_contacts[index] = new_value_contact
    assert sorted(old_contacts,
                  key=Contact.id_or_max) == sorted(new_contacts,
                                                   key=Contact.id_or_max)
    if check_ui:
        new_contacts = map(
            lambda x: Contact(id=x.id,
                              firstname=x.firstname.strip(),
                              lastname=x.lastname.strip()),
            db.get_contact_list())
        assert sorted(new_contacts, key=Contact.id_or_max) == sorted(
            app.contact.get_contact_list(), key=Contact.id_or_max)
Пример #2
0
def modify_contact(random_contact_from_list, app, name, last):
    new_contact = random_contact_from_list
    new_contact.firstname = name
    new_contact.lastname = last
    app.contact.edit_contact_by_id(new_contact.id, new_contact,
                                   Date("1", "March", "1880"),
                                   Date("2", "March", "2333"))
    return new_contact
Пример #3
0
def test_add_contact_to_group(app,db, orm):
    if len(db.get_group_list()) == 0:
        app.group.create(Group("oOo"))
    if len(db.get_contact_list()) == 0:
        app.contact.create(Contact("TIMMY"), Date("20", "March", "1990"), Date("20", "June", "2000"))
    contact = random.choice(db.get_contact_list())
    group = random.choice(db.get_group_list())
    app.contact.add_contact_in_group_by_id(contact.id,group.id)
    assert contact in orm.get_contacts_in_group(group = group)
Пример #4
0
def test_add_contact(app, json_contacts, db, check_ui):
    contact = json_contacts
    old_contacts = db.get_contact_list()
    app.contact.create(contact, Date("20", "March", "1990"),
                       Date("20", "June", "2000"))
    new_contacts = db.get_contact_list()
    old_contacts.append(contact)
    assert sorted(old_contacts,
                  key=Contact.id_or_max) == sorted(new_contacts,
                                                   key=Contact.id_or_max)
    if check_ui:
        new_contacts = map(
            lambda x: Contact(id=x.id,
                              firstname=x.firstname.strip(),
                              lastname=x.lastname.strip()),
            db.get_contact_list())
        assert sorted(new_contacts, key=Contact.id_or_max) == sorted(
            app.contact.get_contact_list(), key=Contact.id_or_max)
Пример #5
0
def test_delete_first_contact(app, db, check_ui):
    if len(db.get_contact_list()) == 0:
        app.contact.create(Contact("TIMMY"), Date("20", "March", "1990"),
                           Date("20", "June", "2000"))
    old_contacts = db.get_contact_list()
    contact = random.choice(old_contacts)
    app.contact.delete_contact_by_id(contact.id)
    new_contacts = db.get_contact_list()
    old_contacts.remove(contact)
    assert old_contacts == new_contacts
    if check_ui:
        new_contacts = map(
            lambda x: Contact(id=x.id,
                              firstname=x.firstname.strip(),
                              lastname=x.lastname.strip()),
            db.get_contact_list())
        assert sorted(new_contacts, key=Contact.id_or_max) == sorted(
            app.contact.get_contact_list(), key=Contact.id_or_max)
def test_delete_contact_from_group(app, db, orm):
    if len(db.get_group_list()) == 0:
        app.group.create(Group("oOo"))
    if len(db.get_contact_list()) == 0:
        app.contact.create(Contact("TIMMY"), Date("20", "March", "1990"),
                           Date("20", "June", "2000"))
    groups_with_contacts = []
    for g in db.get_group_list():
        if len(orm.get_contacts_in_group(g)) >= 1:
            groups_with_contacts.append(g)
    if len(groups_with_contacts) == 0:
        contact = random.choice(db.get_contact_list())
        group = random.choice(db.get_group_list())
        app.contact.add_contact_in_group_by_id(contact.id, group.id)
        groups_with_contacts.append(group)
    contact_in_group = orm.get_contacts_in_group(groups_with_contacts[0])[0]
    app.contact.delete_contact_from_group_by_id(contact_in_group.id,
                                                groups_with_contacts[0].id)
    assert contact_in_group not in orm.get_contacts_in_group(
        groups_with_contacts[0])
    assert contact_in_group in orm.get_contacts_not_in_group(
        groups_with_contacts[0])
Пример #7
0
def non_empty_contact_list(db, app):
    if len(db.get_contact_list()) == 0:
        app.contact.create(Contact("TIMMY"), Date("20", "March", "1990"),
                           Date("20", "June", "2000"))
    return db.get_contact_list()
Пример #8
0
def add_new_contact(app, new_contact):
    app.contact.create(new_contact, Date("20", "March", "1990"),
                       Date("20", "June", "2000"))