Esempio n. 1
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 = DbFixture(host=db_config["host"], name=db_config["name"], user=db_config["user"],
                           password=db_config["password"])
Esempio n. 2
0
 def init_fixtures(self):
     web_config = self.target['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.target['db']
     self.dbfixture = DbFixture(host=db_config['host'], name=db_config['name'], user=db_config['user'],
                                password=db_config['password'])
Esempio n. 3
0
class Addressbook:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self,config="target.json", browser="chrome"):
        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']
        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'])

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


    def create_group(self, name, header, footer):
            self.fixture.group.create(Group(name=name, header=header, footer=footer))
Esempio n. 4
0
class AddressBook:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config="target.json", browser="Chrome"):
        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']
        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'])

    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 get_group_list(self):
        return self.dbfixture.get_group_list()

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

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

    def group_lists_should_be_equal(self, list1, list2):
        assert sorted(list1, key=Group.id_or_max) == sorted(list2, key=Group.id_or_max)
Esempio n. 5
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']
        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'])

    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 get_group_list(self):
        return self.dbfixture.get_group_list()

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

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

    def modify_group(self, source_group, new_data_group):
        self.fixture.group.modify_group_by_id(source_group.id, new_data_group)

    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 new_contact(self, lastname, firstname, address, home, mobile, work, phone2, email, email2, email3):
        return Contact(lastname=lastname, firstname=firstname, address=address,
                   home=home, mobile=mobile, work=work, phone2=phone2,
                   email=email, email2=email2, email3=email3)

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

    def add_contact(self, contact):
        self.fixture.contact.add(contact)

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

    def modify_contact(self, source_contact, new_data_contact):
        self.fixture.contact.modify_contact_by_id(source_contact.id, new_data_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)
Esempio n. 6
0
class AddressBook:

    ROBOT_LIBRARY_SCOPE = 'TEST_SUITE'

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

    def init_fixtures(self):
        self.fixture = Application(browser=self.browser, base_url=self.target['web']['baseUrl'])
        self.fixture.session.check_login(username=self.target['web']['username'], password=self.target['web']['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'])

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

# GROUPS

    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_groups_list()

    def group_lists_should_be_equal(self, old_list, new_list):
        assert sorted(old_list, key=Group.sorting_id_or_maxsize) == sorted(new_list, key=Group.sorting_id_or_maxsize)

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

# CONTACTS

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

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

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

    def contact_lists_should_be_equal(self, old_list, new_list):
        assert sorted(old_list, key=Contact.sorting_id_or_maxsize) == sorted(new_list, key=Contact.sorting_id_or_maxsize)

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

    def modify_contact(self, contact, new_contact):
        new_contact.id = contact.id  # чтоб в изм. контакте был заданный id, не None. А то будут проблемы при сортировке
        self.fixture.contact.modify_contact_by_id(contact.id, new_contact)
Esempio n. 7
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"]
        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"])

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

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

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

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

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

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

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

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

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

    def change_contact_name(self, contact, new_name):
        edited_contact = contact
        edited_contact.firstname = new_name
        self.fixture.contact.edit_contact_by_id(edited_contact, contact.id)

    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 contact_lists_should_be_equal(self, list1, list2):
        assert sorted(list1, key=Contact.id_or_max) == sorted(list2, key=Contact.id_or_max)
Esempio n. 8
0
 def init_fixture(self):
     web_conf = self.settings['web']
     self.fixture = Generic(browser=self.browser,
                            base_url=web_conf["base_url"])
     self.fixture.session.ensure_login(username=web_conf["username"],
                                       password=web_conf["password"])
     db_conf = self.settings["db"]
     self.dbfixture = DbFixture(host=db_conf["host"],
                                name=db_conf["name"],
                                user=db_conf["username"],
                                password=db_conf["password"])
Esempio n. 9
0
def db(request):
    db_config = load_config(request.config.getoption("--target"))["db"]
    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
Esempio n. 10
0
 def init_fixture(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 = DbFixture(host=db_config["host"], name=db_config["name"], user=db_config["user"],
                                password=db_config["password"])
Esempio n. 11
0
def db(request):
    db_config = load_config(request.config.getoption("--target"))['db']
    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
Esempio n. 12
0
def orm(request):
    db_config = load_config(request.config.getoption("--target"))['db']
    dbfixture = DbFixture(host=db_config["host"],
                          name=db_config["name"],
                          user=db_config["user"],
                          password=db_config["password"])
    return dbfixture
Esempio n. 13
0
def db(request):
    db_config = load_config(request.config.getoption("--target"))['db'] #берем из конфигурации блок db
    dbfixture = DbFixture(host=db_config['host'], name=db_config['name'], user=db_config['user'],
                            password=db_config['password'])
    def end():
        dbfixture.destroy()
    request.addfinalizer(end)
    return dbfixture
Esempio n. 14
0
class AddressBook:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config="config.json", browser="Chrome"):
        self.browser = browser
        config_file_path = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), "..", config)
        print(config_file_path)
        with open(config_file_path) as config_file:
            self.json_config = json.load(config_file)

    def create_group(self, group):
        self.fixture.group.init_new_group_creation()
        self.fixture.group.fill_group_form(group)
        self.fixture.group.submit_new_group_creation()

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

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

    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 init_fixtures(self):
        web_config = self.json_config["web"]
        self.fixture = Application(browser=self.browser,
                                   base_url=web_config["baseUrl"])
        db_config = self.json_config["db"]
        self.dbfixture = DbFixture(host=db_config["host"],
                                   database=db_config["database"],
                                   user=db_config["user"],
                                   password=db_config["password"])
        self.fixture.session.ensure_login(username=web_config["username"],
                                          password=web_config["password"])

    def destroy_fixtures(self):
        self.fixture.teardown()
        self.dbfixture.teardown()
Esempio n. 15
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'])   # Создание фикстуры работы с базой данных
Esempio n. 16
0
def db(request, config):
    dbfixture = DbFixture(host=config["db"]['host'], database=config["db"]['database'], user=config["db"]['user'],
                          password=config["db"]['password'])

    def fin():
        dbfixture.destroy()

    request.addfinalizer(fin)
    return dbfixture
Esempio n. 17
0
def orm(request):
    path = request.config.getoption("--path")
    if path is None:
        path = os.path.dirname(os.path.abspath(__file__))
    db_config = load_config(os.path.join(path, request.config.getoption("--target")))['db']
    dbfixture = DbFixture(host=db_config['host'], database=db_config['database'], user=db_config['user'], password=db_config['password'])
    def fin():
        dbfixture.destroy()
    request.addfinalizer(fin)
    return dbfixture
Esempio n. 18
0
def db(request, config):
    dbfixture = DbFixture(host=config['db']['host'],
                          name=config['db']['name'],
                          user=config['db']['user'],
                          password=config['db']['password'])

    def fin():
        dbfixture.destroy()

    request.addfinalizer(fin)
    return dbfixture
Esempio n. 19
0
def set_db():
    global db
    # db_config = load_config(request.config.getoption("--config"))['db']
    db_config = load_config(config_file_name)['db']
    if db is None or not db.is_valid():
        db = DbFixture(database=db_config['database'],
                       user=db_config['user'],
                       password=db_config['password'],
                       host=db_config['host'],
                       port=db_config['port'])
        print 'SET_DB', db
    return db
Esempio n. 20
0
def db(request):
    db_config = load_config(request.config.getoption('--target'))['db']
    dbfixture = DbFixture(host=db_config["host"],
                          database=db_config["database"],
                          user=db_config["user"],
                          password=db_config["password"])

    def fin():
        dbfixture.destroy()

    request.addfinalizer(fin)
    return dbfixture
Esempio n. 21
0
def db(request):
    db_conf = load_config(request.config.getoption("--settings"))["db"]
    dbfixture = DbFixture(host=db_conf["host"],
                          name=db_conf["name"],
                          user=db_conf["username"],
                          password=db_conf["password"])

    def fin():
        dbfixture.finish()

    request.addfinalizer(fin)
    return dbfixture
Esempio n. 22
0
def db(request, config):
    config_db = config["db"]
    dbfixture = DbFixture(host=config_db["host"],
                          name=config_db["name"],
                          user=config_db["user"],
                          password=config_db["password"])

    def finalizer():
        dbfixture.destroy()

    request.addfinalizer(finalizer)
    return dbfixture
Esempio n. 23
0
def db(request):
    db_config = load_config(pytest.config.getoption('--config'))['db']
    dbfixture = DbFixture(host=db_config['host'],
                          db=db_config['db'],
                          user=db_config['user'],
                          password=db_config['password'])

    def fin():
        dbfixture.destroy()

    request.addfinalizer(fin)
    return dbfixture
Esempio n. 24
0
def db(request):
    db_config = load_config(request.config.getoption("--config"))["db"]
    dbfixture = DbFixture(host=db_config["host"],
                          database=db_config["database"],
                          user=db_config["user"],
                          password=db_config["password"])

    def fin():
        dbfixture.teardown()
        request.addfinalizer(fin)

    return dbfixture
Esempio n. 25
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']
        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.target['db']
        self.dbfixture = DbFixture(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(firstname=firstname, lastname=lastname)

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

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

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

    def modify_contact(self, contact, new_contact):
        self.fixture.contact.modify_contact_by_id(contact.id, new_contact)
        time.sleep(0.1)

    def contact_lists_should_be_equal(self, list1, list2):
        assert sorted(list1, key=Contact.id_or_max) == sorted(list2, key=Contact.id_or_max)
Esempio n. 26
0
def db(request):
    db_config = load_config(request.config.getoption('--target'))[
        'db']  # открыть конфиг из json, часть с db
    dbfixture = DbFixture(host=db_config['host'],
                          name=db_config['name'],
                          user=db_config['user'],
                          password=db_config['password'])

    def final():
        dbfixture.destroy()

    request.addfinalizer(final)
    return dbfixture
Esempio n. 27
0
def db(request
       ):  # request содержит инфо об опциях переданны при запеске фреймворка
    db_config = load_config(request.config.getoption("--target"))['db']
    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
Esempio n. 28
0
def db(request):
    db_config = load_config(request.config.getoption("--target"))['db']
    db_fixture = DbFixture(host=db_config['host'],
                           database=db_config['database'],
                           user=db_config['user'],
                           password=db_config['password'])

    def fin():
        db_fixture.disconect()

    request.addfinalizer(fin)

    return db_fixture
Esempio n. 29
0
def db(
    request
):  #Фикстура для взаимодействия с БД, request содержит инфу об опциях переданных при запуске фреймворка
    db_config = load_config(request.config.getoption("--target"))['db']
    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
Esempio n. 30
0
def db(request):
    global dbfixture
    db_config = load_config(request.config.getoption("--target"))['db']
    if dbfixture is None or not dbfixture.is_valid():
        dbfixture = DbFixture(database=db_config['database'],
                              user=db_config['user'],
                              password=db_config['password'],
                              host=db_config['host'],
                              port=db_config['port'])

    def fin():
        dbfixture.destroy()

    request.addfinalizer(fin)
    return dbfixture
Esempio n. 31
0
class AddressBook:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

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

    def init_fixture(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 = DbFixture(host=db_config["host"], name=db_config["name"], user=db_config["user"],
                                   password=db_config["password"])

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

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

    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 delete_group(self, group):
        self.fixture.group.delete_group_by_id(group.id)

    def group_lists_should_be_equal(self, list1, list2):
        assert sorted(list1, key=Group.id_or_max) == sorted(list2, key=Group.id_or_max)
Esempio n. 32
0
def db(request):
    db_config = load_config(request.config.getoption('--target'))["db"]
    dbfixture = DbFixture(ssh=db_config["ssh"],
                          ssh_host=db_config["ssh_host"],
                          ssh_user=db_config["ssh_user"],
                          ssh_password=db_config["ssh_password"],
                          host=db_config["host"],
                          database_name=db_config["database_name"],
                          user=db_config["user"],
                          password=db_config["password"],
                          user_id=db_config["user_id"])

    def fin():
        dbfixture.destroy()

    request.addfinalizer(fin)
    return dbfixture
Esempio n. 33
0
from fixture.db import DbFixture


#Second Db for users --working
db = DbFixture (host="127.0.0.1", name= "addressbook", user="******", password="")

try:
   users=db.get_user_list()
   for user in users:
       print(user)
   print(len(users))

finally:
    db.destroy()


#First -working
# import mysql.connector
#
# connection = mysql.connector.connect (host="127.0.0.1", database= "addressbook",
#                                       user="******", password="")
#
# try:
#     cursor = connection.cursor()
#     cursor.execute("select * from group_list")
#     for row in cursor.fetchall():
#         print(row)
#
# finally:
#     connection.close()
Esempio n. 34
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) # Сравнение сортированных по идентификатору списков контактов
Esempio n. 35
0
class AddressBook:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config='target.json', browser='chrome'):
        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"]
        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"])

    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 get_group_list(self):
        return self.dbfixture.get_group_list()

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

    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 get_contact_list(self):
        return self.dbfixture.get_contact_list()

    def new_contact(self, firstname, lastname, address, home, mobile):
        return Contact(firstname=firstname,
                       lastname=lastname,
                       address=address,
                       home=home,
                       mobile=mobile)

    def new_contact_data(self, id, firstname, lastname, address, home, mobile):
        return Contact(id=id,
                       firstname=firstname,
                       lastname=lastname,
                       address=address,
                       home=home,
                       mobile=mobile)

    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 edit_contact(self, contact, contact_data):
        self.fixture.contact.edit_contact_by_id(contact.id, contact_data)

    def delete_contact(self, contact):
        self.fixture.contact.delete_by_id_from_edit_form(contact.id)
Esempio n. 36
0
    for row in cursor.fetchall():
        print(row)
finally:
    connection.close()
"""
json_config = None


def load_config(file):
    global json_config
    if json_config is None:
        config_file_path = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), file)
        with open(config_file_path) as config_file:
            json_config = json.load(config_file)
    return json_config


db_config = load_config("config.json")["db"]
dbfixture = DbFixture(host=db_config["host"],
                      database=db_config["database"],
                      user=db_config["user"],
                      password=db_config["password"])

try:
    cursor = dbfixture.connection.cursor()
    cursor.execute("select * from group_list")
    for row in cursor.fetchall():
        print(row)
finally:
    dbfixture.connection.close()
import mysql.connector
from fixture.db import DbFixture

#connection = mysql.connector.connect(host="127.0.0.1", db="addressbook", user="******", password="")
# try:
#     cursor = connection.cursor()
#     cursor.execute("select * from group_list")
#     for row in cursor.fetchall():
#         print(row)
#
# finally:
#     connection.close()

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

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

try:
    contacts = db.get_contact_list()
    for contact in contacts:
        print(contact)
    print(len(contacts))
finally:
    db.destroy()
Esempio n. 38
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 = DbFixture(host=db_config['host'], name=db_config['name'], user=db_config['user'], password=db_config['password'])
Esempio n. 39
0
class AddressBook:
    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

    def __init__(self, config="target.json", browser="chrome"):
        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_fixture(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 = DbFixture(host=db_config['host'],
                                   name=db_config['database'],
                                   user=db_config['user'],
                                   password=db_config['password'])

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

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

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

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

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

    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 get_contact_list(self):
        return self.dbfixture.get_contact_list()

    def new_contact(self, firstname, middlename, lastname, nickname, title,
                    company, address, home, mobile, work, fax, email, email2,
                    email3, homepage, address2, phone2, notes, bday, bmonth,
                    byear, aday, amonth, ayear):
        return Contact(firstname=firstname,
                       middlename=middlename,
                       lastname=lastname,
                       nickname=nickname,
                       title=title,
                       company=company,
                       address1=address,
                       homephone=home,
                       mobilephone=mobile,
                       workphone=work,
                       fax=fax,
                       email1=email,
                       email2=email2,
                       email3=email3,
                       homepage=homepage,
                       bdaydate=bday,
                       bmonth=bmonth,
                       aday=aday,
                       amonth=amonth,
                       byear=byear,
                       ayear=ayear,
                       address2=address2,
                       phone2=phone2,
                       notes1=notes)

    def create_contact(self, contact):
        self.fixture.contact.add_new_contact()
        self.fixture.contact.fill_data(contact)
        self.fixture.contact.submit()

    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, contact):
        self.fixture.contact.edit_contact_by_id(contact.id)

    def edited_contact(self, firstname, middlename, lastname, nickname, title,
                       company, address, home, mobile, work, fax, email,
                       email2, email3, homepage, address2, phone2, notes, bday,
                       bmonth, byear, aday, amonth, ayear):
        return Contact(firstname=firstname,
                       middlename=middlename,
                       lastname=lastname,
                       nickname=nickname,
                       title=title,
                       company=company,
                       address1=address,
                       homephone=home,
                       mobilephone=mobile,
                       workphone=work,
                       fax=fax,
                       email1=email,
                       email2=email2,
                       email3=email3,
                       homepage=homepage,
                       bdaydate=bday,
                       bmonth=bmonth,
                       aday=aday,
                       amonth=amonth,
                       byear=byear,
                       ayear=ayear,
                       address2=address2,
                       phone2=phone2,
                       notes1=notes)

    def update_contact(self, contact):
        self.fixture.contact.fill_data(contact)
        self.fixture.contact.update()
        time.sleep(5)

    def update_old_list(self, old_contact, contact):
        for i in old_contact:
            if i.id == contact.id:
                i.firstname = contact.firstname
                i.lastname = contact.lastname
        return old_contact