def test_add_contact_to_group(app, db):
    if len(db.get_contact_list(app)) == 0:
        app.contact.create(Contact(firstname="Ernest", lastname="Hemingway"))
    if len(db.get_group_list()) == 0:
        app.group.create(Group(name="group_to_add_contact"))

    def choose_random_contact():
        contacts = db.get_contact_list(app)
        return random.choice(contacts)

    def choose_random_group():
        groups = db.get_group_list()
        return random.choice(groups)

    contact = None
    orm_db = ORMFixture(host="127.0.0.1", name="addressbook", user="******", password="")

    while contact is None:
        contact = choose_random_contact()
        group = choose_random_group()
        old_contacts = orm_db.get_contacts_in_group(group)
        if contact not in old_contacts:
            app.contact.add_contact_to_group(app, contact, group)
            new_contacts = orm_db.get_contacts_in_group(group)
            old_contacts.append(contact)
            assert sorted(new_contacts, key=Group.id_or_max) == sorted(old_contacts, key=Group.id_or_max)
        else:
            contact = None
def test_delete_contact_from_group(app, db):
    if app.contacts.count() == 0:
        app.contacts.add_contact(Contact(firstname = "NewContact"))
    base = ORMFixture(host="127.0.0.1", name="addressbook", user="******", password="")
    old = base.get_contacts_in_group(Group(id="59"))
    contact = random.choice(old)
    app.contacts.delete_contact_from_group(contact.id)
    new = base.get_contacts_in_group(Group(id="59"))
    assert len(old) == len(new) + 1
Ejemplo n.º 3
0
 def verify_address_in_group_list(self, group_id):
     db = ORMFixture(host="127.0.0.1", name="addressbook", user="******", password="")
     try:
         contacts_in_group = []
         l = db.get_contacts_in_group(Group(id=group_id))
         for item in l:
             contacts_in_group.append(item)
         return contacts_in_group
     finally:
         pass
Ejemplo n.º 4
0
 def init_fixtures(self):
     web_config = self.target['web']
     self.fixture = Application(browser=self.browser,
                                base_url=web_config['baseUrl'])
     self.fixture.session.ensure_login(username=web_config['username'],
                                       password=web_config['password'])
     db_config = self.target['db']
     self.ormfixture = ORMFixture(host=db_config['host'],
                                  name=db_config['name'],
                                  user=db_config['user'],
                                  password=db_config['password'])
Ejemplo n.º 5
0
 def init_fixtures(self):
     web_config = self.target["web"]
     self.fixture = Application(browser=self.browser,
                                base_url=web_config["baseUrl"])
     self.fixture.session.ensure_login(username=web_config["username"],
                                       password=web_config["password"])
     db_config = self.target["db"]
     self.dbfixture = ORMFixture(host=db_config["host"],
                                 name=db_config["name"],
                                 user=db_config["user"],
                                 password=db_config["password"])
Ejemplo n.º 6
0
class ContactBook:
    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config="target.json", browser="chrome"):
        self.browser = browser
        config_name = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   "..", config)
        with open(config_name) as config_file:
            self.target = json.load(config_file)

    def init_fixtures(self):
        web_config = self.target["web"]
        self.fixture = Application(browser=self.browser,
                                   base_url=web_config["baseUrl"])
        self.fixture.session.ensure_login(username=web_config["username"],
                                          password=web_config["password"])
        db_config = self.target["db"]
        self.dbfixture = ORMFixture(host=db_config["host"],
                                    name=db_config["name"],
                                    user=db_config["user"],
                                    password=db_config["password"])

    def destroy_fixtures(self):
        self.dbfixture.destroy()
        self.fixture.destroy()

    def new_contact(self, firstname, lastname):
        return Contact(first_name=firstname, last_name=lastname)

    def create_contact(self, contact):
        self.fixture.contact.add_new(contact)

    def get_contact_list(self):
        return self.dbfixture.get_contact_list()

    def contact_lists_should_be_equal(self, list1, list2):
        assert sorted(list1,
                      key=Contact.id_or_max) == sorted(list2,
                                                       key=Contact.id_or_max)

    def delete_contact(self, contact):
        self.fixture.contact.delete_contact_by_id(contact.id)

    def update_contact(self, contact_old, contact_new):
        self.fixture.contact.update_contact_by_id(contact_new, contact_old.id)

    def update_value_in_list(self, contact_list, contact_to_update,
                             contact_with_new_data):
        # NOTE: this action is based on the shallow copying of the objects and greatly on immutability
        contact = contact_list[contact_list.index(contact_to_update)]
        contact.first_name = contact_with_new_data.first_name
        contact.last_name = contact_with_new_data.last_name
Ejemplo n.º 7
0
def test_add_contact_in_group(app, db):
    db = ORMFixture(host="127.0.0.1",
                    name="addressbook",
                    user="******",
                    password="")
    with allure.step('Check group and contact'):
        if len(db.get_group_list()) == 0:
            app.group.creation(Group(name="test"))
        if len(db.get_contact_list()) == 0:
            app.contact.creation(Contact(first_name="test"))
    with allure.step('Given a group list'):
        old_groups = db.get_group_list()
    with allure.step(
            'Given a group, contact not in group and contact in group'):
        group = random.choice(old_groups)
        group_id = group.id
        contacts_without_group = db.get_contacts_not_in_group(
            Group(id=group_id))
        contact = random.choice(contacts_without_group)
        contact_id = contact.id
        old_contacts_in_group = db.get_contacts_in_group(Group(id=group_id))
    with allure.step('When I add a contact %s to the group %s' %
                     (contact, group)):
        app.contact.add_contact_to_group(contact_id, group_id)
    with allure.step(
            'Then the new contacts in group list is equal to the old contacts in group list with the added contact'
    ):
        new_contacts_in_group = db.get_contacts_in_group(Group(id=group_id))
        old_contacts_in_group.append(contact)
        assert sorted(new_contacts_in_group,
                      key=Contact.id_or_max) == sorted(old_contacts_in_group,
                                                       key=Contact.id_or_max)
def test_add_contact_to_group(app):
    db = ORMFixture(host="127.0.0.1",
                    name="addressbook",
                    user="******",
                    password="")

    #Проверяем наличие групп и контактов (что в приложении есть хотя бы одна группа и один контакт).
    group_list = db.get_group_list()
    if len(group_list) == 0:
        app.group.create(Group(name="For adding contact"))
        group_list = db.get_group_list()

    group = group_list[randrange(len(group_list))]

    #проверить, что существуют контакты, которые можно добавить в группу (и предварительно создавать новый контакт или группу, если все контакты добавлены во все группы).
    contact_list = db.get_contacts_not_in_group(group)
    if len(contact_list) == 0:
        app.contact.create_new_contact(
            Contact(name="Add to group", lastname="Smuth"))
        contact_list = db.get_contacts_not_in_group(group)

    #Для всех тестов надо вместо первой попавшейся группы и контакта выбирать именно такой контакт, который можно добавить в группу или удалить из группы.
    contact = contact_list[randrange(len(contact_list))]
    old_contacts_in_group = db.get_contacts_in_group(group)

    app.contact.add_contact_to_group_by_id(contact.id, group.id)

    old_contacts_in_group.append(contact)
    #Сравнивать надо изменившиеся списки групп контакта (который добавляем или удаляем из группы), или списки контактов, состоящих в той группе, которую добавляли или удаляли контакт.
    new_contacts_in_group = db.get_contacts_in_group(group)
    assert sorted(old_contacts_in_group,
                  key=Contact.id_or_max) == sorted(new_contacts_in_group,
                                                   key=Contact.id_or_max)
Ejemplo n.º 9
0
def test_eq_of_all_contacts_db_with_ui(app):
    ui = sorted(app.contact.get_contact_list(), key=Contact.id_or_max)
    db = ORMFixture(host='127.0.0.1',
                    name='addressbook',
                    user='******',
                    password='')
    db_list = sorted(db.get_contact_list(), key=Contact.id_or_max)
    for i in range(len(ui)):
        assert ui[i].all_phones_from_homepage == merge_phones_like_on_homepage(
            db_list[i])
        assert ui[i].firstname == db_list[i].firstname
        assert ui[i].lastname == db_list[i].lastname
        assert ui[i].address == db_list[i].address
        assert ui[i].allemails == merge_emails_like_on_homepage(db_list[i])
Ejemplo n.º 10
0
def test_all_contacts_homepage(app):
    db = ORMFixture(host='localhost', name='addressbook', user='******', password='')
    if len(db.get_contact_list()) == 0:
        app.contact.create(Contact(firstname="testname", lastname="testlastname",
                                   address="testaddress"))
    contacts_from_db = sorted(db.get_contact_list(), key=Contact.id_or_max)
    contacts_from_page = sorted(app.contact.get_contacts_list(), key=Contact.id_or_max)
    for contact in contacts_from_page:
        index = contacts_from_page.index(contact)
        contact_from_db = contacts_from_db[index]
        assert contact.firstname == contact_from_db.firstname
        assert contact.lastname == contact_from_db.lastname
        assert contact.address == contact_from_db.address
        assert contact.all_phones_from_page == merge_phones_like_on_home_page(contact_from_db)
        assert contact.all_mails_from_page == merge_mails_like_on_home_page(contact_from_db)
Ejemplo n.º 11
0
def db(request):
    db_config = load_config(request.config.getoption("--target"))["db"]
    dbfixture = ORMFixture(host=db_config["host"],
                           database=db_config["database"],
                           user=db_config["user"],
                           password=db_config["password"])
    return dbfixture
Ejemplo n.º 12
0
def db(request):
    db_config= load_config(request.config.getoption("--target"))['db']

    dbfixture = ORMFixture(host=db_config['host'], name = db_config['name'], user = db_config['user'], password = db_config['password'])


    return dbfixture
Ejemplo n.º 13
0
def orm(request):
    db_config = load_config(request.config.getoption("--target"))['db']
    ormfixture = ORMFixture(host=db_config['host'],
                            database=db_config['database'],
                            user=db_config['user'],
                            password=db_config['password'])
    return ormfixture
Ejemplo n.º 14
0
def orm(request):
    orm_conf = load_config(request.config.getoption("--settings"))["db"]
    ormfixture = ORMFixture(host=orm_conf["host"],
                            name=orm_conf["name"],
                            user=orm_conf["username"],
                            password=orm_conf["password"])
    return ormfixture
Ejemplo n.º 15
0
def db(request):
    db_config = load_config(request.config.getoption("--target"))['db']
    dbfixture = ORMFixture(host=db_config['host'], name=db_config['name'], user=db_config['user'], password=db_config['password'])
    def fin():
        pass #fixture.destroy()
    request.addfinalizer(fin)
    return dbfixture
Ejemplo n.º 16
0
def orm(request):
    orm_config = load_config(request.config.getoption('--target'))['db']
    ormfixtute = ORMFixture(host=orm_config['host'],
                            name=orm_config['name'],
                            user=orm_config['user'],
                            password=orm_config['password'])
    return ormfixtute
Ejemplo n.º 17
0
def orm(request):
    db_config = load_config(pytest.config.getoption('--config'))['db']
    orm_fixture = ORMFixture(host=db_config['host'],
                             db=db_config['db'],
                             user=db_config['user'],
                             password=db_config['password'])
    return orm_fixture
Ejemplo n.º 18
0
def orm(request):
    db_config = load_config(request.config.getoption("--target"))['db']
    dbfixture = ORMFixture(host=db_config["host"],
                           user=db_config["user"],
                           password=db_config["password"],
                           db=db_config["db"])
    return dbfixture
Ejemplo n.º 19
0
def db_orm(request):
    db_config = load_confg(request.config.getoption("--target"))["db"]
    dbfixture = ORMFixture(host=db_config["host"], name=db_config["name"], user=db_config["user"], password=db_config["password"])
    def fin():
        pass
    request.addfinalizer(fin)
    return dbfixture
Ejemplo n.º 20
0
def orm(request):
    db_config = load_config(request.config.getoption('--configuration'))['db']
    ormfixture = ORMFixture(host=db_config['host'], name=db_config['name'], user=db_config['user'], password=db_config['password'])
    # def fin():
    #     ormfixture.destroy()
    # request.addfinalizer(fin)
    return ormfixture
Ejemplo n.º 21
0
def orm(request):
    db_config = load_config(request.config.getoption("--target"))["db"]
    ormfixture = ORMFixture(host=db_config["host"],
                            name=db_config["name"],
                            user=db_config["user"],
                            password=db_config["password"])
    return ormfixture
Ejemplo n.º 22
0
def orm(request, config):
    # db_config = config['db']
    ormfixture = ORMFixture(host=config['db']['host'],
                            name=config['db']['name'],
                            user=config['db']['user'],
                            password=config['db']['password'])

    return ormfixture
Ejemplo n.º 23
0
 def init_fixtures(self):
     web_config = self.target["web"]                                     # Получение данных конфигурации выполнения из файла для работы с Web
     self.fixture = Application(browser=self.browser, base_url=web_config['baseUrl'])
     self.fixture.session.ensure_login(username=web_config['username'], password=web_config['password']) # Авторизация пользователя
     db_config = self.target['db']                                       # Получение данных конфигурации выполнения из файла для работы с базой данных
     self.dbfixture = DbFixture(host=db_config['host'], name=db_config['name'], user=db_config['user'], password=db_config['password'])   # Создание фикстуры работы с базой данных
     orm_config = self.target['db']                                      # Получение данных конфигурации выполнения из файла для работы с базой данных
     self.ormfixture = ORMFixture(host=orm_config['host'], name=orm_config['name'], user=orm_config['user'], password=orm_config['password'])   # Создание фикстуры работы с базой данных
Ejemplo n.º 24
0
def test_del_some_contact_from_group(app):
    db = ORMFixture(host='localhost',
                    name='addressbook',
                    user='******',
                    password='')
    if len(db.get_group_list()) == 0:
        app.group.create(Group(name='Testname'))
    if len(db.get_contact_list()) == 0:
        app.contact.create(
            Contact(firstname="testname",
                    lastname="testlastname",
                    address="testaddress"))
    group_to_del = random.choice(db.get_group_list())
    old_group_contacts = db.get_contacts_in_group(group_to_del)
    if len(old_group_contacts) == 0:
        contact_to_add = random.choice(db.get_contact_list)
        app.contact.add_in_group_by_id(contact_to_add.id, group_to_del.id)
        old_group_contacts.append(contact_to_add)
    contact = random.choice(old_group_contacts)
    app.contact.del_from_group_by_id(contact.id, group_to_del.id)
    old_group_contacts.remove(contact)
    new_group_contacts = db.get_contacts_in_group(group_to_del)
    assert sorted(old_group_contacts,
                  key=Contact.id_or_max) == sorted(new_group_contacts,
                                                   key=Contact.id_or_max)
def test_check_all_contacts_data(app):
    if app.contact.count() == 0:
        app.contact.create(
            Contact(firstname="firstname",
                    lastname="lastname",
                    address="address",
                    home_phone="123",
                    work_phone="456",
                    mobile_phone="789",
                    secondary_phone="135",
                    email1="*****@*****.**",
                    email2="*****@*****.**",
                    email3="*****@*****.**"))
    with allure.step('Given contact list from db and from homepage'):
        contacts_from_homepage = sorted(app.contact.get_contact_list(),
                                        key=Contact.id_or_max)
        db = ORMFixture(host="127.0.0.1",
                        name="addressbook",
                        user="******",
                        password="")
        contacts_from_db = sorted(db.get_contact_list(), key=Contact.id_or_max)
    with allure.step(
            'When I get contact email and phones from db and homepage'):
        for c in contacts_from_db:
            c.all_phones_from_home_page = merge_phones_like_on_home_page(c)
            c.all_emails_from_home_page = merge_emails_like_on_home_page(c)
        list_of_phones_from_db = []
        list_of_emails_from_db = []
        list_of_phones_from_home_page = []
        list_of_emails_from_home_page = []
        for i in range(0, len(contacts_from_db)):
            list_of_phones_from_db.append(
                contacts_from_db[i].all_phones_from_home_page)
            list_of_emails_from_db.append(
                contacts_from_db[i].all_emails_from_home_page)
            list_of_phones_from_home_page.append(
                contacts_from_homepage[i].all_phones_from_home_page)
            list_of_emails_from_home_page.append(
                contacts_from_homepage[i].all_emails_from_home_page)
    with allure.step(
            'Then contact data from db should be equal to contact data from home page'
    ):
        assert contacts_from_db == contacts_from_homepage
        assert list_of_phones_from_db == list_of_phones_from_home_page
        assert list_of_emails_from_db == list_of_emails_from_home_page
Ejemplo n.º 26
0
def orm(request):
    orm_config = load_config(request.config.getoption("--target"))['orm']
    ormfixture = ORMFixture(host=orm_config['host'],
                            name=orm_config['name'],
                            user=orm_config['user'],
                            password=orm_config['password'])
    #   def fin():
    #       ormfixture.destroy()
    #   request.addfinalizer(fin)
    return ormfixture
Ejemplo n.º 27
0
def orm(request):
    orm_config = load_config(request.config.getoption("--target"))['db']
    ormfixture = ORMFixture(host=orm_config["host"],
                            name=orm_config["name"],
                            user=orm_config["user"],
                            password=orm_config["password"])
    # def fin():
    #     ormfixture.destroy()
    #request.addfinalizer(fin)
    return ormfixture
Ejemplo n.º 28
0
class AddressBook:
    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config="target.json", browser="chrome"):
        self.browser = browser
        config_name = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   "..", config)
        with open(config_name) as config_file:
            self.target = json.load(config_file)

    def init_fixtures(self):
        web_config = self.target["web"]
        self.fixture = Application(browser=self.browser,
                                   base_url=web_config["baseUrl"])
        self.fixture.session.ensure_login(username=web_config["username"],
                                          password=web_config["password"])
        db_config = self.target["db"]
        self.dbfixture = ORMFixture(host=db_config["host"],
                                    name=db_config["name"],
                                    user=db_config["user"],
                                    password=db_config["password"])

    def destroy_fixtures(self):
        self.dbfixture.destroy()
        self.fixture.destroy()

    def new_group(self, name, header, footer):
        return Group(name=name, header=header, footer=footer)

    def create_group(self, group):
        self.fixture.group.create(group)

    def get_group_list(self):
        return self.dbfixture.get_group_list()

    def group_lists_should_be_equal(self, list1, list2):
        assert sorted(list1,
                      key=Group.id_or_max) == sorted(list2,
                                                     key=Group.id_or_max)

    def delete_group(self, group):
        self.fixture.group.delete_group_by_id(group.id)
Ejemplo n.º 29
0
def orm(request
        ):  # request содержит инфо об опциях переданны при запеске фреймворка
    orm_config = load_config(request.config.getoption("--target"))['db']
    ormfixture = ORMFixture(host=orm_config['host'],
                            name=orm_config['name'],
                            user=orm_config['user'],
                            password=orm_config['password'])
    #def fin():
    #    dbfixture.destroy()
    #request.addfinalizer(fin)
    return ormfixture
Ejemplo n.º 30
0
def db(request):
    db_config = load_config(request.config.getoption("--target"))['db']
    dbfixture = ORMFixture(host=db_config["host"],
                           name=db_config["name"],
                           user=db_config["user"],
                           password=db_config["password"])
    # dbfixture = DbFixture(host=db_config["host"], name=db_config["name"], user=db_config["user"], password=db_config["password"])
    # def fin():
    #     dbfixture.destroy()
    # request.addfinalizer(fin)
    return dbfixture
Ejemplo n.º 31
0
 def check_contacts_in_group(self, group_id):
     db = ORMFixture(host="127.0.0.1",
                     name="addressbook",
                     user="******",
                     password="")
     """ Сколько контактов входит в группу"""
     try:
         l = db.get_contacts_in_group(Group(id=group_id))
         assert_group = None
         if l != "" or []:
             assert_group = True
         else:
             print("There is no contacts in group %s" % group_id)
             assert_group = False
         assert assert_group
         for item in l:
             print(item)
         print(len(l))
     finally:
         pass
Ejemplo n.º 32
0
def orm(request):  # метод для инициализации фикстуры
    orm_config = load_config(request.config.getoption("--target"))['db']
    ormfixture = ORMFixture(host=orm_config['host'],
                            name=orm_config['name'],
                            user=orm_config['user'],
                            password=orm_config['password'])

    def fin():
        pass  #ormfixture.destroy()

    request.addfinalizer(fin)
    return ormfixture
Ejemplo n.º 33
0
def orm_db(request):
    db_config = load_config(request.config.getoption("--target"))["db"]
    orm_fixture = ORMFixture(host=db_config["host"],
                             database=db_config["name"],
                             user=db_config["user"],
                             password=db_config["password"])

    def fin():
        pass

    request.addfinalizer(fin)
    return orm_fixture
Ejemplo n.º 34
0
def db(request):
    db_config = load_config(request.config.getoption("--target"))['db']
    dbfixture = ORMFixture(host='127.0.0.1',
                           name='addressbook',
                           user='******',
                           password='')

    def fin():
        pass

    request.addfinalizer(fin)
    return dbfixture
def test_add_contact_in_group(app, db):
    db = ORMFixture(host="127.0.0.1", name = "addressbook", user="******", password="")
    if len(db.get_contact_list()) == 0:
        app.contact.create(Contact(last="test"))
    if len(db.get_group_list()) == 0:
        app.group.create(Group(name="test"))
    old_contacts = db.get_contact_list()
    contact = random.choice(old_contacts)
    old_groups = db.get_group_list()
    group = random.choice(old_groups)
    if len(db.get_contacts_in_group(group)) == 0:
        app.contact.add_contact_to_group(contact.id, group)
    app.contact.show_contacts_in_group(group)
    app.contact.delete_contact_from_group(group)
    app.contact.show_contacts_in_group(group)
    list_contacts = app.contact.get_contact_list()
    def clean(contact):
        return Contact(id = contact.id, first = contact.first.strip(), last = contact.last.strip())
    db_list = map(clean, db.get_contacts_in_group(group))
    assert sorted(list_contacts, key = Contact.id_or_max) == sorted(db_list, key = Contact.id_or_max)
# -*- coding: utf-8 -*-
import mysql.connector
from fixture.orm import ORMFixture
from model.group import Group
from model.contact import Contact

db = ORMFixture(host="127.0.0.1",name="addressbook",user="******",password="")


connection = mysql.connector.connect(host="127.0.0.1",database="addressbook", user="******", password="")


try:
    l = db.get_group_list()
    for item in l:
                print(item)
finally:
    pass #db.destroy() ORM автоматически закрывает сессию с БД


try:
    l = db.get_contact_list()
    for item in l:
                print(item)
finally:
    pass #db.destroy() ORM автоматически закрывает сессию с БД


try:
    l = db.get_contacts_in_group(Group(id="804"))
    for item in l:
Ejemplo n.º 37
0
import mysql.connector
from tests_contract.contact_lib import Contact
from fixture.orm import ORMFixture


db = ORMFixture(host='127.0.0.1', name='addressbook', user='******', password='')

try:
    groups = db.get_contact_list()
    for group in groups:
        print group
    print len(groups)
finally:
    pass
    #db.destroy()


'''
try:
    cursor = connection.cursor()
    cursor.execute('select id, firstname, middlename, lastname, nickname, title, company, address, home, '
                   'mobile, work, fax, email, email2, email3, homepage, address2, phone2, notes '
                   'from addressbook')
    for row in cursor:
        print (row)

        (id, firstname, middlename, lastname, nickname, title, company, address, home, mobile, work, fax,
         email, email2, email3, homepage, address2, phone2, notes) = row

        list.append(Contact(first_name=firstname, last_name=lastname,
                    middle_name=middlename, nickname=nickname,
from fixture.orm import ORMFixture
from model.group import Group


db = ORMFixture(host='127.0.0.1', name='addressbook', user='******', password='')


try:
    l = db.get_contacts_in_group(Group(id="163"))
    for item in l:
        print(item)
    print(len(l))
finally:
    pass # db.destroy()
Ejemplo n.º 39
0
 def init_fixtures(self):
     web_config = self.config['web']
     self.fixture = Application(browser=self.browser, baseURL=web_config["baseURL"])
     self.fixture.session.ensure_login(username=web_config["username"], password=web_config["password"])
     db_config = self.config['db']
     self.dbfixture = ORMFixture(host=db_config['host'], name=db_config['name'], user=db_config['user'], password=db_config['password'])
__author__ = 'Arseniy'
from fixture.orm import ORMFixture
from model.group import Group
from model.contact import Contact

db = ORMFixture(host="127.0.0.1", name="addressbook", user="******", password="")

try:
    gr = db.find_group_by_id(Group(id=145))
    db.add_contact_to_group(Contact(id=67), gr)
finally:
    pass # db.destroy()
from fixture.orm import ORMFixture
from model.group import Group

db = ORMFixture(host="127.0.0.1", name="addressbook", user="******", password="")

try:
    l = db.get_contacts_not_in_group(Group(id=42))
    for item in l:
        print(item)
    print(len(l))
finally:
    pass
from fixture.orm import ORMFixture
from model.group import Group

db = ORMFixture(host='127.0.0.1', name="addressbook", user="******", password="")

try:
    l = db.get_contacts_in_group(Group(id='147'))
    # l = db.get_contact_list()
    for item in l:
        print(item)
    print(len(l))

finally:
    pass
__author__ = '1'
from fixture.orm import ORMFixture
from model.group import Group

db = ORMFixture(host = "127.0.0.1", name = "addressbook", user = "******", password = "")

try:
    l = db.get_address_not_in_group(Group(id="11"))
    for item in l:
        print(item)
    print(len(l))
finally:
    pass
from fixture.orm import ORMFixture
from model.group import Group

db = ORMFixture(host="127.0.0.1", name="addressbook", user="******", password="")

try:
    l = db.get_contacts_in_group(Group(id="59"))
    for item in l:
        print(item)
    print(len(l))
finally:
    pass #db.destroy()

Ejemplo n.º 45
0
from fixture.orm import ORMFixture
from model.group import Group


db = ORMFixture(host = '127.0.0.1',name = 'addressbook', user = '******', password = '')

try:
    l = db.get_contact_list_in_groups()
    for item in l:
        print(item)
    print(len(l))
finally:
    pass#db.destroy()
# -*- coding: utf-8 -*-
from fixture.orm import ORMFixture
from model.group import Group


db = ORMFixture(host="127.0.0.1", name="addressbook", user="******", password="")

try:
    l = db.get_contacts_not_in_group(Group(id='269'))
    for item in l:
        print(item)
    print(len(l))
finally:
    pass #db.destroy()



# try:
#     l = db.get_contacts_in_group(Group(id='269'))
#     for item in l:
#         print(item)
#     print(len(l))
# finally:
#     pass #db.destroy()
Ejemplo n.º 47
0
__author__ = 'Lenusik'
from fixture.orm import ORMFixture
from model.group import Group

db = ORMFixture(host="127.0.0.1", name="addressbook", user="******", password="")

try:
    l = db.get_contacts_not_in_group(Group(id='106'))
    for item in l:
        print(item)
    print(len(l))
finally:
    pass #db.destroy()
Ejemplo n.º 48
0
__author__ = 'msergeyx'

from fixture.orm import ORMFixture
from model.group import Group

db = ORMFixture(host="127.0.0.1", name="addressbook", user="******", password="")

try:
    l = db.get_cont_not_in_group(Group(id="234"))
    for item in l:
        print(item)
    print(len(l))
finally:
    pass # db.destroy()
Ejemplo n.º 49
0
from fixture.orm import ORMFixture
from model.group import Group

db = ORMFixture(host="127.0.0.1", name="addressbook", user="******", password="")

try:
   l= db.get_users_in_group(Group(id="3"))
   for item in l:
       print(item)
   print(len(l))

finally:
   pass



# db = ORMFixture(host="127.0.0.1", name="addressbook", user="******", password="")
#
# try:
#    l=db.get_user_list()
#    for item in l:
#        print(item)
#    print(len(l))
#
# finally:
#    pass
#import mysql.connector
#import pymysql.cursors
from fixture.orm import ORMFixture
from model.group import Group

db = ORMFixture(host = "127.0.0.1",
             name = "addressbook",
             user = "******",
             password = "")

try:
    l = db.get_contacts_not_in_group(Group(id="212"))
    print(l)
finally:
    pass
Ejemplo n.º 51
0
class AddressBook:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'                                      # Едиый объект для всего тестового набора

    def __init__(self, config="target.json", browser="firefox"):
        self.browser = browser
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", config)    # Определение пути к конфигурационному файлу по умолчанию
        with open(config_file) as f:                                        # Открыть файл, контроль автоматического закрытия после выполнения блока команд
            self.target = json.load(f)                                      # Загрузка данных из файла

    # Инициализация (создание) фикстур
    def init_fixtures(self):
        web_config = self.target["web"]                                     # Получение данных конфигурации выполнения из файла для работы с Web
        self.fixture = Application(browser=self.browser, base_url=web_config['baseUrl'])
        self.fixture.session.ensure_login(username=web_config['username'], password=web_config['password']) # Авторизация пользователя
        db_config = self.target['db']                                       # Получение данных конфигурации выполнения из файла для работы с базой данных
        self.dbfixture = DbFixture(host=db_config['host'], name=db_config['name'], user=db_config['user'], password=db_config['password'])   # Создание фикстуры работы с базой данных
        orm_config = self.target['db']                                      # Получение данных конфигурации выполнения из файла для работы с базой данных
        self.ormfixture = ORMFixture(host=orm_config['host'], name=orm_config['name'], user=orm_config['user'], password=orm_config['password'])   # Создание фикстуры работы с базой данных

    # Уничтожение фикстур
    def destroy_fixtures(self):
        self.dbfixture.destroy()
        self.fixture.destroy()
        self.ormfixture.destroy()

    # Определение контакта
    def new_address(self, first_name, middle_name, last_name, address):
        return Address(first_name=first_name, middle_name=middle_name, last_name=last_name, address=address)    # Контакт

    # Переопределение контакта по идетфикатору
    def new_address_with_id(self, id, first_name, middle_name, last_name, address):
        return Address(id=id, first_name=first_name, middle_name=middle_name, last_name=last_name, address=address)    # Контакт

    # Получение идентификатора контакта из списка по его номеру
    def get_address_id_by_index_from_the_list(self, index, address_list):
        return address_list[index].id                                       # Тдентификатор контакта

    # Получение списка контактов
    def get_address_list(self):
        return self.ormfixture.get_address_list()                           # Список контактов

    # Получение непустого списка контактов
    def get_not_empty_address_list(self):
        if len(self.ormfixture.get_address_list()) == 0:                    # Проверка наличия хотябы одного контакта в списке
            self.fixture.address.create(Address(first_name="Михаил", middle_name="Алексеевич", last_name="Новиков", nickname="M.Novikov", title="Title", company="КБ ДОРС", address="Федеративный пр. д.15 к.4", tel_home="001-13-59", tel_mobile="002-13-59", tel_work="003-13-59", tel_fax="004-13-59", web_email="*****@*****.**", web_email2="*****@*****.**", web_email3="*****@*****.**", web_homepage="http://software-testing.ru", birthday_day=14, birthday_month=11, birthday_year="1986", anniversary_day=1, anniversary_month=1, anniversary_year="2000", sec_address="Secondary Address", home="Home", notes="Notes"))    # Создание контакта на случай пустого списка
        return self.get_address_list()                                      # Список контактов

    # Создание контакта
    def create_address(self, address):
        self.fixture.address.create(address)                                # Создание нового контакта

    # Удаление контакта
    def delete_address(self, address):
        self.fixture.address.delete_address_by_id(address.id)               # Удаление контакта по идентификатору

    # Изменение контакта
    def modify_address(self, address):
        self.fixture.address.modify_address_by_id(address)                  # Изменение контакта по идентификатору

    # Проверка равенства списков контактов
    def address_lists_should_be_equal(self, list1, list2):
        assert sorted(list1, key=Address.id_or_max) == sorted(list2, key=Address.id_or_max) # Сравнение сортированных по идентификатору списков контактов
Ejemplo n.º 52
0
import mysql.connector
from tests_contract.contact_lib import Contact
from fixture.orm import ORMFixture


db = ORMFixture(host='127.0.0.1', name='addressbook', user='******', password='')

try:
    groups = db.get_contacts_in_groups()
    for group in groups:
        print group
    print len(groups)
finally:
    pass
    #db.destroy()


'''
try:
    cursor = connection.cursor()
    cursor.execute('select id, firstname, middlename, lastname, nickname, title, company, address, home, '
                   'mobile, work, fax, email, email2, email3, homepage, address2, phone2, notes '
                   'from addressbook')
    for row in cursor:
        print (row)

        (id, firstname, middlename, lastname, nickname, title, company, address, home, mobile, work, fax,
         email, email2, email3, homepage, address2, phone2, notes) = row

        list.append(Contact(first_name=firstname, last_name=lastname,
                    middle_name=middlename, nickname=nickname,
import pymysql.cursors
from fixture.orm import ORMFixture
from model.group import Group

db = ORMFixture(host="127.0.0.1", name='addressbook', user="******", password="")

try:
    # l = db.get_contacts_not_in_group(Group(id="12"))
    # for item in l:
    #     print(item)
    # print(len(l))
    #
    # l_in_group = db.get_contacts_in_group(Group(id="12"))
    # for item in l_in_group:
    #     print(item)
    # print(len(l_in_group))

    # l_without_group = db.get_contacts_without_group()
    # for item in l_without_group:
    #     print(item)
    # print(len(l_without_group))

    l_group_with_contacts = db.get_groups_with_contacts()
    for item in l_group_with_contacts:
        print(item)
    print(len(l_group_with_contacts))

finally:
    pass

Ejemplo n.º 54
0
__author__ = "e.lyzlov"
from fixture.orm import ORMFixture

db = ORMFixture(host="127.0.0.1", name="addressbook", user="******", password="")

try:
    l = db.get_contact_list()
    for item in l:
        print(item)
    print(len(l))
finally:
    pass  # connection.close
Ejemplo n.º 55
0
__author__ = 'Dzmitry'
from fixture.orm import ORMFixture
from model.group import Group

db = ORMFixture(host="127.0.0.1", name="addressbook", user="******", password="")

try:
    l = db.get_grops_not_in_group(Group(id="26"))
    for i in l:
        print(i)
    print(len(l))
finally:
    pass #db.destroy()
Ejemplo n.º 56
0
class Addressbook:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config="config.json", browser="chrome"):
        self.browser = browser
        conf = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", config)
        with open(conf) as f:
            self.config = json.load(f)

    def init_fixtures(self):
        web_config = self.config['web']
        self.fixture = Application(browser=self.browser, baseURL=web_config["baseURL"])
        self.fixture.session.ensure_login(username=web_config["username"], password=web_config["password"])
        db_config = self.config['db']
        self.dbfixture = ORMFixture(host=db_config['host'], name=db_config['name'], user=db_config['user'], password=db_config['password'])

    def destroy_fixtures(self):
        #self.dbfixture.destroy
        self.fixture.destroy()

    def create_group(self, group):
        self.fixture.group.create(group)

    def get_group_list(self):
        return self.dbfixture.get_list_groups()

    def new_group(self, name, header, footer):
        return Group(name=name, header=header, footer=footer)

    def group_lists_should_be_equal(self, list1, list2):
        assert sorted(list1, key=Group.id_or_max) == sorted(list2, key=Group.id_or_max)

    def delete_group(self, group):
        self.fixture.group.delete_group_by_id(group.id)

    def edit_group(self, random_group, edit_group):
        edit_group.id = random_group.id
        self.fixture.group.edit_group_by_id(edit_group)

    def replace_values_list(self, old_list, index, edit_value):
        old_list[index] = edit_value

    def get_contact_list(self):
        return self.dbfixture.get_list_contacts()

    def new_contact(self, firstname=None, lastname=None, middlename=None, nickname=None, title=None, company=None,
                    address=None, email2=None, email3=None, work_phone=None, mobile_phone=None, home_phone=None, fax=None,
                    homepage=None, notes=None, phone2=None, address2=None):
        return Contact(firstname=firstname, middlename=middlename, lastname=lastname, nickname=nickname, title=title,
                       company=company, address1=address, home_phone=home_phone, mobile_phone=mobile_phone,
                       work_phone=work_phone, fax=fax, email2=email2, email3=email3, homepage=homepage,
                       address2=address2, phone2=phone2, notes=notes)

    def create_contact(self, contact):
        self.fixture.contact.create(contact)

    def contact_lists_should_be_equal(self, list1, list2):
        assert sorted(list1, key=Contact.id_or_max) == sorted(list2, key=Contact.id_or_max)

    def delete_contact(self, contact):
        self.fixture.contact.delete_contact_by_id(contact.id)

    def edit_contact(self, random_contact, edit_contact):
        edit_contact.id = random_contact.id
        self.fixture.contact.edit_contact_by_id(edit_contact)
from mysql import connector
from fixture.orm import ORMFixture
from model.group import Group

db = ORMFixture(host="127.0.0.1", name="addressbook", user="******", password="")

try:
    l = db.get_contacts_in_group(Group(id="230"))
    for item in l:
        print(item)
    print(len(l))
finally:
    pass
# -*- coding: utf-8 -*-

from fixture.orm import ORMFixture
from model.group import Group
from model.contact import Contact

db = ORMFixture(host="127.0.0.1", name="addressbook", user="******", password="")

try:
    l = db.get_groups_without_contact(Contact(id="1"))
    for item in l:
        print(item)
    print(len(l))
finally:
    pass # db.destroy()
Ejemplo n.º 59
0
# __author__ = 'irina.chegodaeva'
from fixture.orm import ORMFixture
from model.group import Group
import mysql.connector


db = ORMFixture(host="127.0.0.1", name="addressbook", user="******", password="")

connection = mysql.connector.connect(host="127.0.0.1", database="addressbook", user="******", password="")
try:

    connection.autocommit = True
    cursor = connection.cursor()
    cursor.execute("select * from group_list")
    for row in cursor.fetchall():
        print(row)
    l = db.get_contacts_not_in_group(Group(id="171"))
    for item in l:
        print(item)
    print(len(l))
finally:
    connection.close()
    pass
# try:
#     groups = db.get_group_list()
#     for group in groups:
#         print(group)
#     print(len(groups))
# finally:
#     db.destroy()

# # -----------------
#
# db = ORMFixture(host="127.0.0.1", name="addressbook", user="******", password="")
#
# try:
#     l = db.get_contact_list()
#     for item in l:
#         print(item)
#     print(len(l))
# finally:
#     pass

# -----------------

db = ORMFixture(host="127.0.0.1", name="addressbook", user="******", password="")

try:
    l = db.get_contacts_not_in_group(Group(id=327))
    for item in l:
        print(item)
    print(len(l))
finally:
    pass