def test_add_contact_in_group(app):
    if len(db.get_group_list()) == 0:
        app.group.create(Group(name="test_for_add_contact_in_group"))
    if len(db.get_contact_list()) == 0 or len(
            db.create_contactid_list_from_contacts_not_in_group()) == 0:
        app.contact.add_new_contact(
            Contact(first_name="Test",
                    last_name="add contact in group",
                    email="*****@*****.**"))
    group_id = db.create_groupid_list()[0]
    contact_id = db.create_contactid_list_from_contacts_not_in_group()[0]
    app.contact.add_contact_in_group(contact_id, group_id)
    assert len(db.get_contacts_in_group(Group(id=group_id))) > 0
    assert contact_id in db.create_contactid_list_contacts_in_group(
        Group(id=group_id))
コード例 #2
0
def test_add_contact_to_group(app):
    orm = ORMFixture(host="127.0.0.1",
                     name="addressbook",
                     user="******",
                     password="")
    # Check for available contacts and groups
    if len(orm.get_contact_list()) == 0:
        app.contact.create(
            Contact(firstname="Fname",
                    middlename="Mname",
                    lastname="Lname",
                    nickname="Nick",
                    title="TestTitle",
                    company="TestCompany",
                    address="TestAddress",
                    homephone="1111111",
                    mobilephone="2222222",
                    workphone="3333333",
                    fax="fax",
                    email="*****@*****.**",
                    email2="*****@*****.**",
                    email3="*****@*****.**",
                    homepage="homepage",
                    birth="1980",
                    secondaryaddress="TestAddress2",
                    secondaryphone="4444444"))
    if len(orm.get_group_list()) == 0:
        app.group.create(
            Group(name="test_name", header="test_header",
                  footer="test_footer"))
    # Selection of random group and contact
    contact = random.choice(orm.get_contact_list())
    group = random.choice(orm.get_group_list())
    old_contacts_in_group = orm.get_contacts_in_group(group)
    # Adding of contact to group
    app.contact.add_contact_to_group(contact.id, group.name)
    new_contacts_in_group = orm.get_contacts_in_group(group)
    if len(old_contacts_in_group) == len(new_contacts_in_group):
        print(
            "\n",
            "Same group was chosen for the selected contact, please retry or create more groups"
        )
    else:
        assert len(old_contacts_in_group) + 1 == len(new_contacts_in_group)
        for contact_in_group in new_contacts_in_group:
            assert (contact_in_group.id == contact.id)
            print("\n", "Contact", contact.firstname,
                  "was successfully added to group", group.name)
コード例 #3
0
def test_phones_on_home_page(app):
    contact = Contact(first_name="My first",
                      last_name="Contact",
                      nickname="Nickname",
                      email="*****@*****.**",
                      homepage="www.pythontraining.com",
                      homephone="+79261111111",
                      workphone="+7888888",
                      mobilephone="+3333333",
                      secondaryphone="+222222222")
    if app.contact.count() == 0:
        app.contact.add_new_contact(contact)
    contact_from_home_page = app.contact.get_contact_info_from_home_page(0)
    contact_from_edit_page = app.contact.get_contact_info_from_edit_page(0)
    assert contact_from_home_page.all_phones == merge_phones_like_on_home_page(
        contact_from_edit_page)
コード例 #4
0
def test_add_random_contact_to_random_group(app):
    orm = ORMFixture(host="127.0.0.1",
                     name="addressbook",
                     user="******",
                     password="")
    groups = orm.get_group_list()
    contacts = orm.get_contact_list()
    if len(contacts) == 0:
        app.contact.create((Contact(firstname="firstname",
                                    middlename="middlename",
                                    lastname="lastname",
                                    nickname="nickname",
                                    title="title",
                                    company="company",
                                    address="address",
                                    homephone="home",
                                    mobilephone="mobile",
                                    workphone="work",
                                    fax="fax",
                                    email="email",
                                    homepage="homepage",
                                    address2="address2",
                                    secondaryphone="phone2",
                                    notes="notes")))
    if len(groups) == 0:
        app.group.create(Group(name="test"))
    app.contact.open_contact_list_page()
    # get random id contact and group
    contact = random.choice(contacts)
    contact_id = contact.id
    group = random.choice(groups)
    group_name = group.name
    group_id = group.id
    # add contact to random group
    old_contacts_in_groups = orm.get_contacts_in_group(Group(id=group_id))
    app.contact.add_contact_to_group(contact_id, group_name)
    # verified contact in group
    new_contacts_in_groups = orm.get_contacts_in_group(Group(id=group_id))
    if len(old_contacts_in_groups) == len(new_contacts_in_groups):
        print("Contact wasnt' added, randomly choosed same group")
    else:
        assert len(old_contacts_in_groups) + 1 == len(new_contacts_in_groups)
        for contact_in_group in new_contacts_in_groups:
            assert (contact_in_group.id == contact_id)
コード例 #5
0
from fixture.contact import Contact

testdata = [
    Contact(firstname="firstname1", lastname="lastname1", middlename="middlename1",
            nickname="nickname1", company="company",
            address="address", homepage="homepage",
            email2="email2", address2="address2",
            email="email", homephone="homephone",
            mobilephone="mobilephone", workphone="workphone",
            secondaryphone="secondaryphone")
]
コード例 #6
0
 def convert(contact):
     return Contact(id=str(contact.id), firstname=contact.firstname, lastname=contact.lastname)
コード例 #7
0
def contact_for_modify(firstname, lastname, address, random_contact):
    return Contact(firstname=firstname,
                   lastname=lastname,
                   address=address,
                   id=random_contact.id)
コード例 #8
0
 def clean(contact_cl):
     return Contact(id=contact_cl.id,
                    firstname=contact_cl.firstname.strip())
コード例 #9
0
def non_empty_contact_list(db, app):
    if len(db.get_contact_list()) == 0:
        app.contact.create(Contact(firstname="Hanna", lastname="Martynenko"))
    return db.get_contact_list()
コード例 #10
0
def new_contact(firstname, lastname, address):
    return Contact(firstname=firstname, lastname=lastname, address=address)
コード例 #11
0
import pytest

contact1 = Contact(firstname="addbeforechng",
                   middlename="",
                   lastname="",
                   nickname="",
                   title="",
                   company="",
                   address="",
                   home_phone="1",
                   mobile_phone="11",
                   work_phone="2",
                   fax="32",
                   email="*****@*****.**",
                   email2="*****@*****.**",
                   email3="*****@*****.**",
                   homepage="12.kz",
                   bday="7",
                   bmonth="May",
                   byear="1974",
                   aday="2",
                   amonth="January",
                   ayear="2001",
                   address2="a2, www2",
                   phone2="132",
                   notes="qwey2",
                   photo=os.path.join(
                       os.path.dirname(os.path.abspath(__file__)), "..",
                       "photo.png"))

コード例 #12
0
def test_del_random_contact_from_group(app, db):
    orm = ORMFixture(host="127.0.0.1",
                     name="addressbook",
                     user="******",
                     password="")
    groups = orm.get_group_list()
    contacts = orm.get_contact_list()
    if len(contacts) == 0:
        app.contact.create((Contact(firstname="firstname",
                                    middlename="middlename",
                                    lastname="lastname",
                                    nickname="nickname",
                                    title="title",
                                    company="company",
                                    address="address",
                                    homephone="home",
                                    mobilephone="mobile",
                                    workphone="work",
                                    fax="fax",
                                    email="email",
                                    homepage="homepage",
                                    address2="address2",
                                    secondaryphone="phone2",
                                    notes="notes")))
    if len(groups) == 0:
        app.group.create(Group(name="test"))
    app.contact.open_contact_list_page()
    # check contacts in group presence
    contacts_in_group = db.get_all_contacts_in_group()
    if len(contacts_in_group) == 0:
        # add contact in group
        contact = random.choice(contacts)
        contact_id = contact.id
        group = random.choice(groups)
        group_name = group.name
        group_id = group.id
        # add contact to random group
        old_contacts_in_groups = orm.get_contacts_in_group(Group(id=group_id))
        app.contact.add_contact_to_group(contact_id, group_name)
        # verified contact in group
        new_contacts_in_groups = orm.get_contacts_in_group(Group(id=group_id))
        if len(old_contacts_in_groups) == len(new_contacts_in_groups):
            print("Contact wasnt' added, randomly choosed same group")
        else:
            assert len(old_contacts_in_groups) + 1 == len(
                new_contacts_in_groups)
            for contact_in_group in new_contacts_in_groups:
                assert (contact_in_group.id == contact_id)

    # delete random contact from group
    contacts_in_group = db.get_all_contacts_in_group()
    contact_in_group = random.choice(contacts_in_group)
    contact_id = contact_in_group.id
    group_id = contact_in_group.group_id
    # get group name
    group_name = None
    for g in groups:
        if str(g.id) == str(group_id):
            group_name = g.name
    if group_name == None:
        raise ValueError("Can't find group_id")
    print("-------> " + str(group_name))
    app.contact.delete_contact_from_group(contact_id, group_name)
    contacts_in_groups_after_deletion = db.get_all_contacts_in_group()
    assert len(contacts_in_group) - 1 == len(contacts_in_groups_after_deletion)