예제 #1
0
def app(request):
    global fixture
    #global target
    browser = request.config.getoption("--browser")
    web_config = load_config(request.config.getoption("--target"))['web']
    #    if target is None:
    #        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), request.config.getoption("--target"))
    #        with open(config_file) as f:
    #            target = json.load(f)
    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
예제 #2
0
def app(request):
    global fixture
    global target
    browser = request.config.getoption("--browser")
    if target is None:
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   request.config.getoption("--target"))
        with open(config_file) as f:
            target = json.load(f)
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser, base_url=target["baseURL"])
    fixture.session.ensure_login(username=target["username"],
                                 password=target["password"])
    return fixture
예제 #3
0
def app():
    """
    Before each test method:
     1. Create an application fixture
        - if it doesn't exist or
        - if fixture doesn't valid (no opened browser)
     2. Login
    :return: app fixture
    """
    global app_fixture
    if not app_fixture or not app_fixture.is_valid():
        app_fixture = Application()
    app_fixture.session.ensure_login(username="******", password="******")
    return app_fixture
예제 #4
0
def app(request):
    global fixture


    if fixture is None :
        mbt_hosts = load_mbt_hosts()
        mbt_hosts_write = [x for x in mbt_hosts if x.write ]
        mbt_hosts_read = [x for x in mbt_hosts if x.read ]

        mbt_conn= load_mbt_conn()

        fixture = Application(mbt_hosts, mbt_hosts_write, mbt_hosts_read, mbt_conn)

    return fixture
예제 #5
0
파일: conftest.py 프로젝트: dkhannanova/pdo
def app(request):
    global fixture
    global target
    browser = request.config.getoption("--browser")
    path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                        request.config.getoption("--target"))
    if target is None:
        with open(path) as config:
            target = json.load(config)
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser, base_url=target['base_url'])
        fixture.session.login(username=target['username'],
                              password=target['password'])
    return fixture
예제 #6
0
def app(request):
    global fixture
    global target
    browser = request.config.getoption("--browser")
    if target is None:
        # определение директории проекта
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   request.config.getoption("--target"))
        with open(config_file) as f:
            target = json.load(f)
    if fixture is None or not fixture.is_valid():  #  to create first fixture
        fixture = Application(browser=browser, base_url=target['baseURL'])
    fixture.session.ensure_login(username=target['username'],
                                 password=target['password'])
    return fixture
예제 #7
0
def app(request):
    global fixture
    #    global target
    browser = request.config.getoption("--browser")
    web_config = load_config(request.config.getoption("--target"))['web']
    #    if target is None:
    #        # Определяем путь относительно файла conftest.py - указываем путь к файлу, чтобы не быть привязанным в тестах к рабочей директории
    #        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), request.config.getoption("--target"))
    #        with open(config_file) as f:
    #            target = json.load(f)
    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
def app(request, db):
    global fixture_app

    browser = request.config.getoption("--browser")
    web_config = load_config(request.config.getoption("--config"))["web"]

    if fixture_app is None or not fixture_app.is_valid():
        fixture_app = Application(browser=browser,
                                  base_url=web_config["baseUrl"],
                                  db=db)

    fixture_app.session.ensure_login(username=web_config["username"],
                                     password=web_config["password"])

    return fixture_app
def app(request, config):
    global fixture
    global target

    browser = request.config.getoption("--browser")

    web_config = config['web']
    webadmin = config['webadmin']

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

    fixture.session.ensure_login(username=webadmin['user'], password=webadmin['password'])

    return fixture
예제 #10
0
def app(request):
    global web_app
    global target
    browser = request.config.getoption("--browser")
    if target is None:
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   request.config.getoption("--target"))
        with open(config_file) as f:
            target = json.load(f)
    if web_app is None or not web_app.is_valid():
        web_app = Application(browser=browser, base_url=target['baseUrl'])
    web_app.session_helper.ensure_login(username=target['username'],
                                        password=target['password'])

    return web_app
예제 #11
0
파일: conftest.py 프로젝트: diBorgia/mantis
def app(request, config):
    global fixture
    # через реквест получаем доступ к параметру
    browser = request.config.getoption("--browser")
    #config =load_config(request.config.getoption("--target"))["web"]
    #ситуация перед вызовом первой тестовой функции
    # если фикстура уже создана, н.проверить, не испортилась ли она
    if fixture is None or not fixture.is_valid():
        #тогда надо фикстуру проинициализировать
        fixture = Application(browser=browser,
                              config=config)  #url=config["web"]['baseUrl'])
    #проверка нужно выполнять логин или не нужно
    fixture.session.ensure_login(username=config["webAdmin"]["username"],
                                 password=config['webAdmin']["password"])
    return fixture
예제 #12
0
def app(request):

    global fixture

    browser = request.config.getoption(
        "--browser")  # получаем доступ к сохраненному параметру 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
예제 #13
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=browser, base_url=web_config['baseUrl'])

    fixture.session.ensure_login(username=web_config['username'],
                                 password=web_config['password'])

    return fixture
예제 #14
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=browser, baseUrl=web_config['baseUrl']
        )  #непосредстевнно сама фикстура (набор вспомогательных методов)

# непосредстевнно сама фикстура (набор вспомогательных методов)
    fixture.session.ensure_login(
        username=web_config["username"],
        password=web_config["password"])  #проверка предусловия
    return fixture
예제 #15
0
def app(request,config): # ,version='1.0'
    global fixture  # глобальная переменная
    browser = request.config.getoption("--browser")
    #web_config=load_config(request.config.getoption("--target"))['web']
    #web = config['web']
   #webadmin = config['webadmin']

    if fixture is None or not fixture.is_valid():

       #fixture = Application(browser=browser,base_url=web_config['baseUrl'])
       fixture = Application(browser=browser, config=config)

    #fixture.session.ensure_login(username=web_config['username'], password=web_config['password'])
    #fixture.session.ensure_login(username=webadmin['username'], password=webadmin['password'])

    return fixture
예제 #16
0
def app(request):
    """Start the app"""
    global fixture
    global config_file
    browser = request.config.getoption("--browser")
    if config_file is None:
        with open(
                os.path.join(os.path.dirname(os.path.abspath(__file__)),
                             request.config.getoption("--target"))) as f:
            config_file = json.load(f)
    if fixture is None or not fixture.is_valid():
        fixture = Application(
            browser, config_file["host_url"])  # initialization of fixture
    fixture.auth.ensure_login(username=config_file["username"],
                              password=config_file["password"])
    return fixture
예제 #17
0
파일: conftest.py 프로젝트: 12ok/selenium
def app(request):
    global fixture
    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['base_url'],
                              user=web_config['user'],
                              password=web_config['password'])

    def fin():
        if fixture:
            fixture.destroy()

    request.addfinalizer(fin)
    return fixture
예제 #18
0
def app(request):
    global fixture
    global target
    browser = request.config.getoption("--browser")
   #Путь к текущему файлу
    config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), request.config.getoption("--target"))
    if target is None:
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), request.config.getoption("--target"))
        #Чтение файла конфигурации
        with open(config_file) as f:#f объект кот.указывает на открытый файл
            target = json.load(f)
    #Пользователь создает новую фикстуру
    if fixture is None or not fixture.is_valid():#Переинициализация фикстуры, с ней что-то случилось и нужно заново создать
        fixture = Application(browser=browser, base_url=target['baseUrl'])
    fixture.session.ensure_login(username=target["username"], password=target["password"])
    return fixture
예제 #19
0
def app(request):
    global fixture
    browser = request.config.getoption("--browser")
    web_config = load_config(request.config.getoption("--target"))['web']
    webadmin_config = load_config(
        request.config.getoption("--target"))['webadmin']
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser, base_url=web_config['base_url'])
    fixture.session.login(username=webadmin_config['username'],
                          password=webadmin_config['password'])

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

    request.addfinalizer(fin)
    return fixture
예제 #20
0
def app(request):
    global fixture
    global env

    browser = request.config.getoption("--browser")
    config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                               request.config.getoption("env"))
    if env is None:
        with open(config_file) as f:
            env = json.load(f)

    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser, base_url=env["base_url"])

    fixture.session.ensure_login(username=env["username"],
                                 password=env["password"])
    return fixture
예제 #21
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, base_url=web_config["baseUrl"])
        #fixture = Application(browser=browser, base_url=config["web"]["baseUrl"])
        #fixture = Application(browser=browser, config=config, base_url=web_config["baseUrl"])
        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
예제 #22
0
def app(request):
    global target
    global fixture
    browser = request.config.getoption("--browser")
    if target is None:
        config_file = os.path.join(
            os.path.dirname(os.path.abspath(__file__)),
            request.config.getoption("--target"))  #необходимо тольк для винды
        with open(config_file) as f:
            target = json.load(f)
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser,
                              base_url=target["base_url"],
                              gmail="")
        fixture.open_station()
        fixture.session.login_as_admin(userName=target["userName"],
                                       admPass=target["admPass"])
    return fixture
예제 #23
0
def app(request):
    global fixture
    global target_main
    if fixture is None or not fixture.is_valid():
        browser = request.config.getoption("--browser")
        if target_main is None:
            config_file = os.path.join(
                os.path.dirname(os.path.abspath(__file__)),
                request.config.getoption("--target"))
            with open(config_file) as f:
                target_main = json.load(f)
                print("1 ", target_main)
        #baseurl = request.config.getoption("--baseurl")
        fixture = Application(browser=browser,
                              baseurl=target_main['web']['baseurl'])
    fixture.session.ensure_log_in(username=target_main['web']['username'],
                                  password=target_main['web']['password'])
    return fixture
예제 #24
0
def app(request):
    #указываем что собираеися использовать глобальную переменную
    global fixture
    global target
    browser = request.config.getoption("--browser")
    #пишем проверку
    if target is None:
        # переменная которая содержит информацию о пути к текущему файлу (преобразовали в абсолютный путь)
        config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   request.config.getoption("--target"))
        #читаем файл джейсон
        with open(config_file) as f:
            target = json.load(f)
    if fixture is None or not fixture.is_valid():
        #функция которая инициализирует фикстуру создает объект класса aplication
        #при инициализации фикстуры нужно передавать параметр
        fixture = Application(browser=browser, base_url=target['baseUrl'])
    fixture.session.ensure_login(username=target["username"],
                                 password=target["password"])
    return fixture
예제 #25
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 or not fixture.is_valid():
        # agent_password = request.config.getoption("--agent_password") - так задавать параметр, если вводить при запуске тестов
        fixture = Application(
            ov_url=target['ov_url'],
            client_login=target['client_login'],
            client_password=target['client_password'],
            arm_ric_url=target['arm_ric_url'],
            agent_login=target['agent_login'],
            agent_password=target['agent_password'],
            browser=target['browser'],
            resource=target['resource'],
            kit=target['kit']
        )  #agent_password=agent_password - так задавать параметр, если вводить при запуске тестов
    return fixture
예제 #26
0
def app(request):
    global fixture
    global target
    global target_path

    browser = request.config.getoption("--browser")
    target_path = request.config.getoption("--targetpath")
    if target_path:
        path = target_path
    else:
        path = os.path.dirname(os.path.abspath(__file__))
    if target is None:
        config_file = os.path.join(path, request.config.getoption('--target'))
        with open(config_file) as f:
            target = json.load(f)
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser, base_url=target["baseUrl"])

    fixture.session.ensure_login(name=target['username'],
                                 password=target["password"])
    return fixture
예제 #27
0
def app(request):
    global fixture
    browser = request.config.getoption("--browser")
    base_url = request.config.getoption("--base_url")
    docker_adr = request.config.getoption("--docker_adr")
    attempt = 0
    resp = None
    if docker_adr:
        while True:
            attempt += 1
            try:
                resp = urllib.request.urlopen(docker_adr)
            except URLError:
                pass
            if resp:
                break
            if attempt > 5:
                sys.exit("No response from docker_adr: " + str(docker_adr))
            time.sleep(4)
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser,
                              base_url=base_url,
                              docker_adr=docker_adr)
    return fixture
예제 #28
0
def app(request):
    global fixture
    global target
    browser = request.config.getoption("--browser")
    account = request.config.getoption("--account")

    if target is None:
        config = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                              request.config.getoption("--target"))
        with open(config) as f:
            target = json.load(f)

    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser)

    if account == "yes":
        # авторизоваться только в том случае, если есть аккаунт, иначе, регистрация (реализовать)
        fixture.session.check_auth(username=target["auth"]["username"],
                                   password=target["auth"]["password"],
                                   name=target["auth"]["name"])
    elif account == "no":
        pass

    return fixture
예제 #29
0
def app(request):
    global fixture
    global target

    if target is None:
        pgl_kvm_config= load_target(request.config.getoption("--target"))["pgl_kvm"]
        pgl_kvm= Pgl_kvm(name_source_image=pgl_kvm_config["name_source_image"],
                         prefix=pgl_kvm_config["prefix"],
                         number_test_set=pgl_kvm_config["number_test_set"],
                         path_meta_json=pgl_kvm_config['path_meta_json'])

        pgl_kvm= reading_parameters_from_jenkins(jen_param=pgl_kvm)

        pgl_ssh_config= load_target(request.config.getoption("--target"))["pgl_ssh"]
        pgl_ssh= Pgl_ssh(ip=pgl_ssh_config["ip"], username=pgl_ssh_config["username"],
                         password=pgl_ssh_config["password"], password_root=pgl_ssh_config["password_root"])
        clone_name_list = []


    if fixture is None :
        fixture = Application(pgl_kvm, pgl_ssh, clone_name_list)

    request.addfinalizer(fixture.destroy)
    return fixture
예제 #30
0
def app(request):
    fixture = Application("C:\\Tools\\AppsForTesting\\Addressbook\\AddressBook.exe")
    request.addfinalizer(fixture.destroy)
    return fixture