Exemplo n.º 1
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)
Exemplo n.º 2
0
def app(request):
    global fixture
    browser = request.config.getoption("--browser")
    web_config = load_config(request.config.getoption("--target"))['web']
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser = browser, base_url = web_config['baseUrl'])
    fixture.open_home_page()
    fixture.session.ensure_login(username = web_config['username'], password = web_config['password'])
    return fixture
Exemplo n.º 3
0
def app(request):
    global fixture
    if fixture is None:
        fixture = Application()
    else:
        if not fixture.is_valid():
            fixture = Application()
    fixture.session.ensure_login(username="******", password="******")
    return fixture
Exemplo n.º 4
0
def app(request):
    global fixture
    browser = request.config.getoption("--browser")
    web_config = load_config(request.config.getoption("--target"))["web"]
    web_config = load_config(request.config.getoption("--target"))["web"]
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser, base_url=web_config["baseUrl"])
        fixture.set_default_user(web_config["userName"], web_config["userPassword"])
    fixture.session.ensure_login_by_default_user()
    return fixture
Exemplo 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.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)
Exemplo n.º 6
0
def app(request):
    global fixture
    browser = request.config.getoption("--browser")
    base_url = request.config.getoption("--baseUrl")
    if fixture is None:
        fixture = Application(browser=browser, base_url=base_url)
    else:
        if not fixture.is_valid():
            fixture = Application(browser=browser, base_url=base_url)
    fixture.session.ensure_login(username="******", password="******")
    return fixture
Exemplo n.º 7
0
def app(request):
    global fixture
    if fixture is None:
        print('create new fixture')
        fixture = Application()
        fixture.wd_helper.open_home_page()
        fixture.session_helper.login_as_admin()
    else:
        if not fixture.is_valid():
            print('rebuild broken fixture')
            fixture = Application()
            fixture.wd_helper.open_home_page()
            fixture.session_helper.login_as_admin()
    return fixture
Exemplo n.º 8
0
def app(request):
    global fixture
    global target
   # if target is None:
    #    with open(request.config.getoption("--target")) as config_file:
     #       target = json.load(config_file)

    if fixture is None:
        fixture = Application(browser = "firefox")

    else:
        if not fixture.is_valid():
            fixture = Application()
    fixture.session.ensure_login(username="******", password="******")
    return fixture
Exemplo n.º 9
0
 def init_fixtures(self):
     web_config = self.target["web"]
     self.fixture = Application(baseurl=web_config["baseURL"])
     self.fixture.session.ensure_login(username=web_config["username"], password=web_config["password"])
     db_config = self.target["db"]
     self.db_fixture = DBFixture(host=db_config["host"], database=db_config["name"], user=db_config["user"],
                            password=db_config["password"])
Exemplo 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"])
Exemplo n.º 11
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'])   # Создание фикстуры работы с базой данных
Exemplo n.º 12
0
def app(request):
    global fixture
    browser = request.config.getoption("--browser")
    web_config = load_config(request.config.getoption("--target"))['web']
    if fixture is None or not fixture.helper.is_valid:
        fixture = Application(browser=browser, baseUrl=web_config['baseUrl'])
    fixture.session.login(username=web_config['username'],
                          password=web_config['password'])
    return fixture
Exemplo n.º 13
0
def app(request, config):
    global fixture
    browser = request.config.getoption("--browser")
    web_config = config['web']
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser, config=config)
    fixture.session.ensure_login(username=web_config["username"],
                                 password=web_config["password"])
    return fixture
Exemplo n.º 14
0
def app(request, config):
    global fixture
    browser = request.config.getoption("--browser")
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser,
                              base_url=config['web']['baseUrl'])
    fixture.session.ensure_login(username=config['web']['username'],
                                 password=config['web']['password'])
    return fixture
Exemplo n.º 15
0
def app(request, config):
    global fixture
    global target
    browser = request.config.getoption("--browser")
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser, config=config)
    fixture.session.ensure_login(username=config["webadmin"]['username'],
                                 password=config["webadmin"]['password'])
    return fixture
Exemplo n.º 16
0
def app(request):
    global fixture
    browser = pytest.config.getoption('--browser')
    web_config = load_config(pytest.config.getoption('--config'))['web']
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser, url=web_config['url'])
    fixture.session.ensure_login(web_config['username'],
                                 web_config['password'])
    return fixture
Exemplo n.º 17
0
def app(request):
    global fixture
    browser = request.config.getoption('--browser')
    web_config = load_config(request.config.getoption("--target"))["web"]
    if (fixture is None) or (not fixture.is_valid()):
        fixture = Application(browser=browser, base_url=web_config["baseUrl"])
    fixture.session.ensure_login(username=web_config['username'],
                                 password=web_config['password'])
    return fixture
Exemplo n.º 18
0
def app(request, config):
    global fixture
    browser = request.config.getoption("--browser")
    environment = request.config.getoption("--environment")
    #check_report_result = request.config.getoption("--check_report_result")
    #web_config = load_config(request.config.getoption("--target"))['dev_marker']
    if fixture is None or not fixture.is_valid():
        fixture = Application(
            browser=browser,
            config=config,
            environment=environment,
            check_report_result=config[environment]['check_report_result'],
            baseUrlSM=config[environment]['baseUrlSM'],
            baseUrlMarker=config[environment]['baseUrlMarker'],
            username=config[environment]['username'],
            password=config[environment]['password'],
            dashboard=config['markertails']['dashboard'],
            newtenders=config['markertails']['newtenders'],
            participation=config['markertails']['participation'],
            watch=config['markertails']['watch'],
            market_potential=config['markertails']['market-potential'],
            planned_purchases=config['markertails']['planned-purchases'],
            company_list=config['markertails']['company_list'],
            solutions=config['markertails']['solutions'],
            reports=config['markertails']['reports'],
            smParticipants=config['SMtails']['Participants'],
            smParticipantsCustomers=config['SMtails']['ParticipantsCustomers'],
            smParticipantsSuppliers=config['SMtails']['ParticipantsSuppliers'],
            smPurchases=config['SMtails']['Purchases'],
            smPrices=config['SMtails']['Prices'],
            smCertificates=config['SMtails']['Certificates'],
            smLicences=config['SMtails']['Licences'],
            smKontrol=config['SMtails']['Kontrol'],
            smreports=config['SMtails']['reports'],
            smMonitorinds=config['SMtails']['Monitorinds'],
            smcompany_list=config['SMtails']['company_list'],
            smPurchases_list=config['SMtails']['Purchases_list'],
            smNmckList=config['SMtails']['NmckList'],
            smUser_History=config['SMtails']['User_History'],
            smlogout=config['SMtails']['logout'],
            smAdminUserInfo=config['AdminSMtails']['UserInfo'],
            smAdminUpravlenie=config['AdminSMtails']['Upravlenie'],
            smAdminShlyuz=config['AdminSMtails']['Shlyuz'],
            smAdminAccessManager=config['AdminSMtails']['AccessManager'],
            smAdminInstructions=config['AdminSMtails']['Instructions'],
            smAdminNotifications=config['AdminSMtails']['Notifications'],
            smAdminNews=config['AdminSMtails']['News'],
            smAdminSessions=config['AdminSMtails']['Sessions'],
            admindashboard=config['AdminMarkertails']['dashboard'],
            adminfind_monitorings=config['AdminMarkertails']
            ['find_monitorings'],
            adminfind_users=config['AdminMarkertails']['find_users'],
            adminfind_publication=config['AdminMarkertails']
            ['find_publication'],
            adminnews=config['AdminMarkertails']['news'])
    #fixture.session.ensure_login(username=web_config['username'], password=web_config['password'])
    return fixture
Exemplo n.º 19
0
def app(request):
    global fixture
    browser = request.config.getoption("--browser")
    web_config = load_config(request.config.getoption("--target"))['web']
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser, base_url=web_config['baseUrl'])
        fixture.session.login("administrator", "root")
    # fixture.session.ensure_login(username=web_config['username'], password=web_config['password'])
    return fixture
Exemplo n.º 20
0
def app(request, config):
    global fixture
    browser = request.config.getoption('--browser')
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser, config=config)
    # TODO для работы тестов раскомитить
    fixture.session.ensure_login(username=config["webadmin"]["username"],
                                 password=config["webadmin"]["password"])
    return fixture
Exemplo n.º 21
0
def app(request):
    global fixture
    browser = request.config.getoption("--browser")
    web_config = load_config(request.config.getoption("--target"))['web']
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser, base_url=web_config["baseurl"])
    fixture.session.ensure_login(username=web_config["username"],
                                 password=web_config["password"])
    return fixture
Exemplo n.º 22
0
def app(request, config):
    global fixture

    browser = request.config.getoption("--browser")
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser, config)

    #fixture.session.login_ensure(config["webadmin"]["username"], config["webadmin"]["password"])
    return fixture
Exemplo n.º 23
0
def app(request):
    global fixture
    browser = request.config.getoption("--browser")
    web_config = load_config(request.config.getoption("--target"))["web"]
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser, base_url=web_config['baseUrl'])
    fixture.session.ensure_login(web_config['username'],
                                 web_config['password'])
    return fixture
Exemplo n.º 24
0
def app(request):
    global fixture
    browser = request.config.getoption("--browser")
    web_config = load_config(request.config.getoption("--target"))['web'] #берем из конфигурации блок web
    if fixture is None or not fixture.is_valid:
        fixture = Application(browser=browser, base_url=web_config['baseUrl'], login=web_config['username'],
                              password=web_config['password']) #создаём фикстуру если она None или не валидная
    fixture.session.ensure_login(username=web_config['username'], password=web_config['password'])
    return fixture
Exemplo n.º 25
0
def app(request):
    global fixture
    web_config = load_config(request.config.getoption("--target"))['web']
    # получаем доступ к сохраненному параметру через объект request
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=web_config['browser'],
                              base_url=web_config['baseUrl'])
    fixture.session.ensure_login(username=web_config['username'],
                                 password=web_config['password'])
    return fixture
Exemplo n.º 26
0
def app(request):
    fixture = Application()
    fixture.session.login(user_name="user101", password="******")

    def fin():
        fixture.session.logout()
        fixture.destroy()

    request.addfinalizer(fin)
    return fixture
Exemplo n.º 27
0
def app(request):
    global fixture
    browser = request.config.getoption("--browser")
    web_config = load_config(request.config.getoption("--target"))['web']
    api_config = load_config(request.config.getoption("--target"))['api']
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser, base_url=web_config['baseUrl'], login=web_config['login'],
                              password=web_config['password'], service=api_config['service'])
    fixture.session.ensure_login(login=web_config['login'], password=web_config['password'])  # check for login logic
    return fixture
Exemplo n.º 28
0
def app(request):
    fixture = Application()
    request.addfinalizer(fixture.destroy)
    return fixture

# @pytest.fixture(scope='session')
# def stop(request):
#     fixture = Application()
#     request.addfinalizer(fixture.destroy)
#     return fixture
Exemplo n.º 29
0
def app(request):
    global fixture
    global target
    web_config = load_config(request.config.getoption("--target"))['web']
    browser = request.config.getoption("--browser")
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser, base_url=web_config['baseURL'])
    fixture.session.ensure_login(user_name=web_config['username'],
                                 user_password=web_config['password'])
    return fixture
Exemplo n.º 30
0
def app():
    global fixture
    if fixture is None:
        fixture = Application()
        fixture.session.login(username="******", password="******")
    # else:
    #     if not fixture.is_valid():
    #         fixture = Application()
    fixture.session.ensure_login(username="******", password="******")
    return fixture
Exemplo n.º 31
0
def run_app(request):
    global configfile
    run_browser = request.config.getoption("--browser")
    if configfile is None:
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   request.config.getoption("--configfile"))
        with open(config_file) as config_file:
            configfile = json.load(config_file)
    fixture = Application(browser=run_browser, base_url=configfile["baseUrl"])
    return fixture
Exemplo n.º 32
0
def app(request, config):
    global fixture
    browser = request.config.getoption("--browser")
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser,
                              base_url=config["web"]["baseUrl"])
    user_info = config["webadmin"]
    fixture.session.ensure_login(username=user_info["username"],
                                 password=user_info["password"])
    return fixture
Exemplo n.º 33
0
def app(request):
    global fixture
    browser = request.config.getoption('--browser')
    web_config = load_config(request.config.getoption('--target'))
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser,
                              baseURL=web_config['web']['baseURL'])
    fixture.session.ensure_login(username=web_config['webadmin']['username'],
                                 password=web_config['webadmin']['password'])
    return fixture
Exemplo n.º 34
0
def appLogin(request):
    fixture = Application()
    fixture.session.login()

    def fin():
        fixture.session.logout()
        fixture.destroy()

    request.addfinalizer(fin)
    return fixture
Exemplo n.º 35
0
def app(request):
    global fixture
    global target
    browser = request.config.getoption("--browser")
    web_config = load_config(request.config.getoption("--target"))["web"]
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser, web_config["baseUrl"])
    fixture.session.ensure_login(web_config["username"],
                                 web_config["password"])
    return fixture
Exemplo n.º 36
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["base_url"])
        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"],
                                   username=db_config["username"],
                                   password=db_config["password"])

    def destroy_fixtures(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_list_should_be_equal(self, new_list, old_list):
        assert sorted(old_list,
                      key=Group.id_or_max) == sorted(new_list,
                                                     key=Group.id_or_max)
Exemplo n.º 37
0
def app(request, config):
    global fixture
    #     global target
    browser = request.config.getoption("--browser")
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser, config=config)


#     fixture.session.ensure_login("administrator", "root")  # для тестов которым нужны админ права
    return fixture
Exemplo n.º 38
0
def app(request, config):
    global fixture
    browser = request.config.getoption("--browser")
    web_config = load_config(request.config.getoption("--target"))['web']
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser, config=config)
    fixture.session.ensure_login(username=config['webadmin']['username'],
                                 password=config['webadmin']['password'])
    # fixture.session.ensure_login(username=web_config['username'], password=web_config['password'])
    return fixture
Exemplo n.º 39
0
def app(request, config):
    global fixture
    browser = request.config.getoption("--browser")
    # web_config = load_config(request.config.getoption("--target"))["web"]#вместо строки используем фикстуру "конфиг"
    # web_config = config["web"]# config["web"] ставим вместо имени переменной в строке №30
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser, config=config)#№9.3 меняем base_url=config["web"]["baseUrl"] на config=config
        # fixture = Application(browser=browser, base_url=config["web"]["baseUrl"]) #закоментировал №9.3 меняем base_url=config["web"]["baseUrl"] на config=config
    # fixture.session.ensure_login(username=config["webadmin"]["username"], password=config["webadmin"]["password"])
    return fixture
Exemplo n.º 40
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 create_group(self, group):
        self.fixture.group.create_group(group)

    def delete_group(self, group):
        self.fixture.group.delete_group_by_id(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)
Exemplo n.º 41
0
def app(request):
    global fixture
    browser = request.config.getoption("--browser")
    url = load_config(request.config.getoption("--target"))["web"]
    credentials = load_config(request.config.getoption("--target"))["webadmin"]
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser, base_url=url["base_url"])
    fixture.session.ensure_login(username=credentials["username"],
                                 password=credentials["password"])
    return fixture
Exemplo n.º 42
0
class addressbook:

    ROBOT_LIBRARY_SCOPE = 'TEST SUITE'

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

    def init_fixtures(self):
        web_config = self.target["web"]
        self.fixture = Application(baseurl=web_config["baseURL"])
        self.fixture.session.ensure_login(username=web_config["username"], password=web_config["password"])
        db_config = self.target["db"]
        self.db_fixture = DBFixture(host=db_config["host"], database=db_config["name"], user=db_config["user"],
                               password=db_config["password"])

    def get_contacts(self):
        return self.db_fixture.get_contacts()

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

    def contacts_should_be_equal(self, old_contacts, new_contacts):
        assert sorted(old_contacts, key=Contact.id_or_max) == sorted(new_contacts, key=Contact.id_or_max)

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

    def delete(self, contact):
        self.fixture.contact.delete_by_id(contact.id)

    def update(self, contact, data):
        self.fixture.contact.update_by_id(contact.id, data)

    def destroy_fixtures(self):
        self.fixture.destroy()
        self.db_fixture.destroy()
Exemplo n.º 43
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)
Exemplo n.º 44
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'])
Exemplo n.º 45
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) # Сравнение сортированных по идентификатору списков контактов
Exemplo n.º 46
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)
Exemplo n.º 47
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'])