Ejemplo n.º 1
0
def test_list_paginator_click_arrow(admin_client, live_server, webdriver):
    selenium = webdriver()
    create_correct_sample_data()
    create_many_entries()
    try:
        selenium.get(live_server + '/characteristic_value_definition/')
        login_as_admin(selenium)
        paginator = selenium.find_elements_by_class_name('paginator')

        button = paginator[0].find_elements_by_css_selector('#page-wrapper li')
        assert button[0] == selenium.find_element_by_css_selector(
            '#page-wrapper .disabled')
        assert button[1] == selenium.find_element_by_css_selector(
            '#page-wrapper .active')
        for i in range(2, 6):
            button[-1].find_element_by_css_selector('#page-wrapper a').click()
            url = '/characteristic_value_definition/?page={}'.format(i)
            assert selenium.current_url == live_server.url + url
            paginator = selenium.find_element_by_class_name('paginator')
            button = paginator.find_elements_by_tag_name('li')
            act = selenium.find_element_by_css_selector('#page-wrapper .active')
            assert button[i] == act
        dis = selenium.find_element_by_css_selector('#page-wrapper .disabled')
        assert button[6] == dis
    finally:
        selenium.quit()
Ejemplo n.º 2
0
def test_list_paginator(admin_client, live_server, webdriver):
    selenium = webdriver()
    create_correct_sample_data()
    try:
        selenium.get(live_server + '/characteristic_value_definition/')
        login_as_admin(selenium)
        rows = selenium.find_elements_by_css_selector('#page-wrapper tr')
        assert len(rows) == 4
        assert not selenium.find_elements_by_class_name('paginator')
        create_many_entries()
        selenium.get(live_server + '/characteristic_value_definition/')
        rows = selenium.find_elements_by_css_selector('#page-wrapper tr')
        assert len(rows) == 21
        paginator = selenium.find_elements_by_class_name('paginator')
        assert paginator
        button = paginator[0].find_elements_by_css_selector('#page-wrapper li')
        assert len(button) == 7
        assert button[0].text == u'«'
        assert button[1].text == '1'
        assert button[2].text == '2'
        assert button[3].text == '3'
        assert button[4].text == '4'
        assert button[5].text == '5'
        assert button[6].text == u'»'
    finally:
        selenium.quit()
Ejemplo n.º 3
0
def test_list_paginator_click_num(admin_client, live_server, webdriver):
    selenium = webdriver()
    create_correct_sample_data()
    create_many_entries()
    try:
        selenium.get(live_server + '/characteristic_value_definition/')
        login_as_admin(selenium)
        paginator = selenium.find_elements_by_class_name('paginator')

        button = paginator[0].find_elements_by_css_selector('#page-wrapper li')
        assert button[1] == selenium.find_element_by_css_selector(
            '#page-wrapper .active')
        for i in range(5, 0, -1):
            button[i].find_element_by_css_selector('#page-wrapper a').click()
            url = '/characteristic_value_definition/?page={}'.format(i)
            assert selenium.current_url == live_server.url + url
            paginator = selenium.find_element_by_class_name('paginator')
            button = paginator.find_elements_by_css_selector('#page-wrapper li')
            active = selenium.find_element_by_css_selector(
                '#page-wrapper .active')
            assert button[i] == active
            row = selenium.find_elements_by_css_selector('#page-wrapper tr')
            if i == 5:
                assert len(row) == 20
            else:
                assert len(row) == 21
    finally:
        selenium.quit()
Ejemplo n.º 4
0
def working_instance(request, live_server,
                     fix_webdriver,      # pylint: disable=W0621
                     transactional_db):  # pylint: disable=W0613
    """
    Create ready to use testing enviroment, with sample datas in the db and
    webdriver instance which is logged in as admin
    """
    def fin(selenium):
        """
        Close the Webdriver
        """
        selenium.quit()

    create_correct_sample_data()
    create_limited_users()
    create_sample_characteristic_values()
    selenium = fix_webdriver()
    selenium.get(live_server.url)
    login_as_admin(selenium)
    request.addfinalizer(lambda: fin(selenium))
    return selenium