コード例 #1
0
def test_user_ranking_course(driver):
    '''Creates a course and students to participate make submits to problems'''

    run_id = driver.generate_id()
    course_alias = 'ut_rank_course_%s' % run_id
    school_name = 'ut_rank_school_%s' % run_id
    assignment_alias = 'ut_rank_hw_%s' % run_id
    problem = 'sumas'

    with driver.login_admin():
        create_course(driver, course_alias, school_name)
        add_students_course(driver, [driver.user_username])
        add_assignment(driver, assignment_alias)
        add_problem_to_assignment(driver, assignment_alias, problem)

    with driver.login_user():
        enter_course(driver, course_alias, assignment_alias)

        driver.wait.until(
            EC.element_to_be_clickable(
                (By.XPATH,
                 ('//a[contains(@href, "#problems/%s")]' %
                  problem)))).click()

        util.create_run(driver, problem, 'Main.cpp11')
        driver.update_score_in_course(problem, assignment_alias)

        driver.wait.until(
            EC.element_to_be_clickable(
                (By.CSS_SELECTOR,
                 'button.details'))).click()

        assert (('show-run:') in
                driver.browser.current_url), driver.browser.current_url

    update_scoreboard_for_assignment(driver, assignment_alias, course_alias)

    with driver.login_admin():
        with driver.page_transition():
            driver.wait.until(
                EC.element_to_be_clickable(
                    (By.XPATH, '//a[@href = "/schools/"]'))).click()

        with driver.page_transition():
            course_url = '/course/%s' % course_alias
            driver.wait.until(
                EC.element_to_be_clickable(
                    (By.XPATH,
                     '//a[@href = "%s"]' % course_url))).click()

        with driver.page_transition():
            driver.wait.until(EC.element_to_be_clickable(
                (By.XPATH,
                 '//a[contains(@href, "/assignment/%s/scoreboard/")]' %
                 assignment_alias))).click()

        run_user = driver.browser.find_element_by_xpath(
            '//td[@class="accepted"]/preceding-sibling::td[1]')
        assert run_user.text == driver.user_username, run_user
コード例 #2
0
ファイル: test_course.py プロジェクト: lhchavez/omegaup
def test_user_ranking_course(driver):
    '''Creates a course and students to participate make submits to problems'''

    run_id = driver.generate_id()
    course_alias = 'ut_rank_course_%s' % run_id
    school_name = 'ut_rank_school_%s' % run_id
    assignment_alias = 'ut_rank_hw_%s' % run_id
    problem = 'sumas'

    with driver.login_admin():
        create_course(driver, course_alias, school_name)
        add_students_course(driver, [driver.user_username])
        add_assignment(driver, assignment_alias)
        add_problem_to_assignment(driver, assignment_alias, problem)

    with driver.login_user():
        enter_course(driver, course_alias, assignment_alias)

        driver.wait.until(
            EC.element_to_be_clickable(
                (By.XPATH,
                 ('//a[contains(@href, "#problems/%s")]' %
                  problem)))).click()

        util.create_run(driver, problem, 'Main.cpp11')
        driver.update_score_in_course(problem, assignment_alias)

        driver.wait.until(
            EC.element_to_be_clickable(
                (By.CSS_SELECTOR,
                 'button.details'))).click()

        assert (('show-run:') in
                driver.browser.current_url), driver.browser.current_url

    update_scoreboard_for_assignment(driver, assignment_alias, course_alias)

    with driver.login_admin():
        with driver.page_transition():
            driver.wait.until(
                EC.element_to_be_clickable(
                    (By.XPATH, '//a[@href = "/schools/"]'))).click()

        with driver.page_transition():
            course_url = '/course/%s' % course_alias
            driver.wait.until(
                EC.element_to_be_clickable(
                    (By.XPATH,
                     '//a[@href = "%s"]' % course_url))).click()

        with driver.page_transition():
            driver.wait.until(EC.element_to_be_clickable(
                (By.XPATH,
                 '//a[contains(@href, "/assignment/%s/scoreboard/")]' %
                 assignment_alias))).click()

        run_user = driver.browser.find_element_by_xpath(
            '//td[contains(@class, "accepted")]/preceding-sibling::td[1]')
        assert run_user.text == driver.user_username, run_user
コード例 #3
0
ファイル: test_course.py プロジェクト: lorenzorivas/omegaup
def test_user_ranking_course(driver):
    '''Creates a course and students to participate make submits to problems'''

    run_id = driver.generate_id()
    course_alias = 'ut_rank_course_%s' % run_id
    school_name = 'ut_rank_school_%s' % run_id
    assignment_alias = 'ut_rank_hw_%s' % run_id
    problem = 'sumas'

    with driver.login_admin():
        create_course(driver, course_alias, school_name)
        add_students_course(driver, [driver.user_username])
        add_assignment(driver, assignment_alias)
        add_problem_to_assignment(driver, assignment_alias, problem)

    with driver.login_user():
        enter_course(driver, course_alias, assignment_alias)

        driver.wait.until(
            EC.element_to_be_clickable(
                (By.XPATH,
                 ('//a[contains(@href, "#problems/%s")]' % problem)))).click()

        util.create_run(driver, problem, 'Main.cpp11')
        driver.update_score_in_course(problem, assignment_alias)

        driver.wait.until(
            EC.element_to_be_clickable(
                (By.CSS_SELECTOR, 'button.details'))).click()

        assert (('show-run:')
                in driver.browser.current_url), driver.browser.current_url

    with driver.login_admin():
        with driver.page_transition():
            driver.wait.until(
                EC.element_to_be_clickable(
                    (By.XPATH, '//a[@href = "/schools/"]'))).click()

        with driver.page_transition():
            driver.wait.until(
                EC.element_to_be_clickable(
                    (By.XPATH, ('//a[@href = "/course/"]')))).click()

        with driver.page_transition():
            course_url = '/course/%s' % course_alias
            driver.wait.until(
                EC.element_to_be_clickable(
                    (By.XPATH, '//a[@href = "%s"]' % course_url))).click()

        with driver.page_transition():
            progress_url = '/course/%s/students/' % course_alias
            driver.wait.until(
                EC.element_to_be_clickable(
                    (By.XPATH, ('//a[@href = "%s"]' % progress_url)))).click()

        assert driver.browser.find_element_by_css_selector(
            'td.score').text == '100'
コード例 #4
0
ファイル: test_smoke.py プロジェクト: yesidays/omegaup
def test_create_problem(driver):
    '''Tests creating a public problem and retrieving it.'''

    problem_alias = 'ut_problem_%s' % driver.generate_id()
    with driver.login_admin():
        util.create_problem(driver, problem_alias)

    with driver.login_user():
        prepare_run(driver, problem_alias)
        assert (problem_alias in driver.browser.find_element_by_xpath(
            '//h1[@class="title"]').get_attribute('innerText'))

        runs_before_submit = driver.browser.find_elements_by_css_selector(
            'td[data-run-status]')

        filename = 'Main.java'
        util.create_run(driver, problem_alias, filename)

        runs_after_submit = driver.browser.find_elements_by_css_selector(
            'td[data-run-status]')

        assert len(runs_before_submit) + 1 == len(runs_after_submit)

        driver.wait.until(
            EC.element_to_be_clickable(
                (By.XPATH,
                 '//button[contains(@class, "details")]'))).click()

        driver.wait.until(
            EC.visibility_of_element_located(
                (By.CSS_SELECTOR, '[data-run-details-view]')))

        textarea = driver.browser.find_element_by_xpath(
            '//form[@data-run-details-view]//div[@class="CodeMirror-code"]')

        assert textarea.text is not None

        resource_path = os.path.join(util.OMEGAUP_ROOT,
                                     'frontend/tests/resources', filename)
        # The text of the CodeMirror editor contains the line number.
        # Non-exact match is needed.
        with open(resource_path, 'r') as f:
            for row in f.read().splitlines():
                if row is not None:
                    assert (row in textarea.text), row

        driver.browser.find_element_by_id('overlay').click()
        driver.update_score(problem_alias)

    with driver.login_user():
        prepare_run(driver, problem_alias)
        driver.wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 '//div[contains(concat(" ", normalize-space(@class), " "), '
                 '" qualitynomination-popup ")]/form[contains(concat(" ", '
                 'normalize-space(@class), " "), " popup ")]')))
コード例 #5
0
def create_run_user(driver, contest_alias, problem, filename, **kwargs):
    '''Makes the user join a course and then creates a run.'''

    enter_contest(driver, contest_alias)

    driver.wait.until(
        EC.element_to_be_clickable(
            (By.XPATH, ('//a[contains(text(), "%s")]/parent::div' %
                        problem.title())))).click()

    util.create_run(driver, problem, filename)
    driver.update_score_in_contest(problem, contest_alias, **kwargs)

    driver.wait.until(
        EC.element_to_be_clickable(
            (By.CSS_SELECTOR, 'button[data-run-details]'))).click()
    assert (('show-run:')
            in driver.browser.current_url), driver.browser.current_url
コード例 #6
0
ファイル: test_contest.py プロジェクト: lhchavez/omegaup
def create_run_user(driver, contest_alias, problem, filename, **kwargs):
    '''Makes the user join a course and then creates a run.'''

    enter_contest(driver, contest_alias)

    driver.wait.until(
        EC.element_to_be_clickable(
            (By.XPATH,
             ('//a[contains(@href, "#problems/%s")]' %
              problem)))).click()

    util.create_run(driver, problem, filename)
    driver.update_score_in_contest(problem, contest_alias, **kwargs)

    driver.wait.until(
        EC.element_to_be_clickable(
            (By.CSS_SELECTOR,
             'button.details'))).click()
    assert (('show-run:') in
            driver.browser.current_url), driver.browser.current_url
コード例 #7
0
ファイル: test_smoke.py プロジェクト: lorenzorivas/omegaup
def test_create_problem(driver):
    '''Tests creating a public problem and retrieving it.'''

    problem_alias = 'unittest_problem_%s' % driver.generate_id()
    create_problem(driver, problem_alias)

    with driver.login_user():
        driver.wait.until(
            EC.element_to_be_clickable(
                (By.ID, 'nav-problems'))).click()
        with driver.page_transition():
            driver.wait.until(
                EC.element_to_be_clickable(
                    (By.XPATH,
                     ('//li[@id = "nav-problems"]'
                      '//a[@href = "/problem/"]')))).click()

        search_box_element = driver.wait.until(
            EC.visibility_of_element_located(
                (By.ID, 'problem-search-box')))
        search_box_element.send_keys(problem_alias)
        with driver.page_transition():
            search_box_element.submit()

        driver.wait.until(
            EC.element_to_be_clickable(
                (By.XPATH,
                 '//a[text() = "%s"]' % problem_alias))).click()
        assert (problem_alias in driver.browser.find_element_by_xpath(
            '//h1[@class="title"]').get_attribute('innerText'))

        runs_before_submit = driver.browser.find_elements_by_xpath(
            '//td[@class="status"]')

        util.create_run(driver, problem_alias, 'Main.java')

        runs_after_submit = driver.browser.find_elements_by_xpath(
            '//td[@class="status"]')

        assert len(runs_before_submit) + 1 == len(runs_after_submit)
コード例 #8
0
ファイル: test_smoke.py プロジェクト: heduenas/omegaup
def test_create_problem(driver):
    '''Tests creating a public problem and retrieving it.'''

    problem_alias = 'ut_problem_%s' % driver.generate_id()
    with driver.login_admin():
        util.create_problem(driver, problem_alias)

    with driver.login_user():
        prepare_run(driver, problem_alias)
        assert (problem_alias in driver.browser.find_element_by_xpath(
            '//h3[@data-problem-title]').get_attribute('innerText'))

        runs_before_submit = driver.browser.find_elements_by_xpath(
            '//div[contains(concat(" ", normalize-space(@class), " "), " '
            'active ")]/div/div/table[contains(concat(" ", normalize-space('
            '@class), " "), " runs ")]/tbody/tr/td[@data-run-status]')

        filename = 'Main.java'
        util.create_run(driver, problem_alias, filename)

        runs_after_submit = driver.browser.find_elements_by_xpath(
            '//div[contains(concat(" ", normalize-space(@class), " "), " '
            'active ")]/div/div/table[contains(concat(" ", normalize-space('
            '@class), " "), " runs ")]/tbody/tr/td[@data-run-status]')

        assert len(runs_before_submit) + 1 == len(runs_after_submit)

        driver.wait.until(
            EC.element_to_be_clickable(
                (By.XPATH,
                 '//button[contains(concat(" ", normalize-space(@class), " "),'
                 ' " details ")]'))).click()

        driver.wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 '//div[contains(concat(" ", normalize-space(@class), " "), " '
                 'active ")]/div[@data-overlay]/div[@data-overlay-popup]/form['
                 '@data-run-details-view]')))

        textarea = driver.browser.find_element_by_xpath(
            '//div[contains(concat(" ", normalize-space(@class), " "), " '
            'active ")]/div[@data-overlay]/div[@data-overlay-popup]/form['
            '@data-run-details-view]//div[@class="CodeMirror-code"]')

        assert textarea.text is not None

        resource_path = os.path.join(util.OMEGAUP_ROOT,
                                     'frontend/tests/resources', filename)
        # The text of the CodeMirror editor contains the line number.
        # Non-exact match is needed.
        with open(resource_path, 'r') as f:
            for row in f.read().splitlines():
                if row is not None:
                    assert (row in textarea.text), row

        driver.browser.find_element_by_xpath(
            '//div[contains(concat(" ", normalize-space(@class), " "), " '
            'active ")]/div[@data-overlay]').click()
        driver.update_score(problem_alias)

    with driver.login_user():
        prepare_run(driver, problem_alias)
        driver.wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 '//div[contains(concat(" ", normalize-space(@class), " "), " '
                 'active ")]/div[@data-overlay]/div[@data-overlay-popup]/form['
                 '@data-promotion-popup]')))

    with driver.login_admin():
        prepare_run(driver, problem_alias)
        util.show_run_details(driver, code='java.util.Scanner')

        driver.wait.until(
            EC.element_to_be_clickable(
                (By.XPATH,
                 '//div[contains(concat(" ", normalize-space(@class), " "), '
                 '" tab-content ")]/div[contains(concat(" ", '
                 'normalize-space(@class), " "), " show ")]/div[@data-overlay]'
                 '/div[@data-overlay-popup]/button'))).click()

        assert driver.browser.current_url.endswith('#runs')

        driver.wait.until(
            EC.element_to_be_clickable(
                (By.XPATH,
                 '//table[contains(concat(" ", normalize-space(@class), " "), '
                 '" runs ")]/tbody/tr/td/div[contains(concat(" ", '
                 'normalize-space(@class), " "), " dropdown ")]/'
                 'button'))).click()

        driver.wait.until(
            EC.element_to_be_clickable(
                (By.XPATH,
                 '//table[contains(concat(" ", normalize-space(@class), " "), '
                 '" runs ")]/tbody/tr/td/div[contains(concat(" ", '
                 'normalize-space(@class), " "), " show ")]/div/button['
                 '@data-actions-rejudge]'))).click()

        global_run = driver.browser.find_element_by_xpath(
            '//table[contains(concat(" ", normalize-space(@class), " "), " '
            'runs ")]/tbody/tr/td[@data-run-status]/span')

        assert global_run.text in ('rejudging', 'AC')
コード例 #9
0
ファイル: test_course.py プロジェクト: yoshoo90/omegaup
def test_user_ranking_course(driver):
    '''Creates a course and students to participate make submits to problems'''

    run_id = driver.generate_id()
    course_alias = 'ut_rank_course_%s' % run_id
    school_name = 'ut_rank_school_%s' % run_id
    assignment_alias = 'ut_rank_hw_%s' % run_id
    problem = 'sumas'

    with driver.login_admin():
        create_course(driver, course_alias, school_name)
        add_students_course(driver, [driver.user_username])
        add_assignment(driver, assignment_alias)
        add_problem_to_assignment(driver, assignment_alias, problem)

    with driver.login_user():
        enter_course(driver, course_alias, assignment_alias)

        driver.wait.until(
            EC.element_to_be_clickable(
                (By.XPATH, ('//a[contains(text(), "%s")]/parent::div' %
                            problem.title())))).click()

        util.create_run(driver, problem, 'Main.cpp17-gcc')
        driver.update_score_in_course(problem, assignment_alias)

        # When user has tried or solved a problem, feedback popup will be shown
        with util.dismiss_status(driver):
            driver.wait.until(
                EC.element_to_be_clickable(
                    (By.CSS_SELECTOR, '.popup button.close'))).click()
            driver.wait.until(
                EC.invisibility_of_element_located(
                    (By.CSS_SELECTOR, '.popup button.close')))

        driver.wait.until(
            EC.element_to_be_clickable(
                (By.XPATH, ('//a[contains(text(), "%s")]/parent::div' %
                            problem.title())))).click()
        driver.wait.until(
            EC.element_to_be_clickable(
                (By.CSS_SELECTOR, 'button[data-run-details]'))).click()

        assert (('show-run:')
                in driver.browser.current_url), driver.browser.current_url

    update_scoreboard_for_assignment(driver, assignment_alias, course_alias)

    with driver.login_admin():
        enter_course_assignments_page(driver, course_alias)
        with driver.page_transition():
            driver.wait.until(
                EC.element_to_be_clickable(
                    (By.XPATH,
                     '//a[contains(@href, "/assignment/%s/scoreboard/")]' %
                     assignment_alias))).click()

        driver.wait.until(
            EC.element_to_be_clickable(
                (By.XPATH, '//input[@class = "toggle-contestants"]'))).click()

        run_user = driver.browser.find_element_by_xpath(
            '//td[contains(@class, "accepted")]/preceding-sibling::td[@class='
            '"user"]')
        assert run_user.text == driver.user_username, run_user

        url = '/course/%s/assignment/%s/scoreboard' % (course_alias,
                                                       assignment_alias)

        enter_course_assignments_page(driver, course_alias)
        util.check_scoreboard_events(driver,
                                     assignment_alias,
                                     url,
                                     num_elements=1,
                                     scoreboard='Public')

        enter_course_assignments_page(driver, course_alias)
        util.check_scoreboard_events(driver,
                                     assignment_alias,
                                     url,
                                     num_elements=1,
                                     scoreboard='Admin')

        enter_course_assignments_page(driver, course_alias)
        with driver.page_transition():
            driver.wait.until(
                EC.element_to_be_clickable(
                    (By.XPATH, '//a[contains(@href, "/course/%s/edit/")]' %
                     course_alias))).click()

        driver.wait.until(
            EC.element_to_be_clickable((
                By.XPATH,
                '//input[@name = "show-scoreboard"][@value="true"]'))).click()

        driver.browser.find_element_by_tag_name('form').submit()
        assert (('/course/%s/edit/' % course_alias)
                in driver.browser.current_url), driver.browser.current_url

    with driver.login_user():
        enter_course(driver, course_alias, assignment_alias, first_time=False)

        driver.wait.until(
            EC.element_to_be_clickable(
                (By.XPATH, ('//a[contains(@href, "#ranking")]')))).click()
        assert (('#ranking')
                in driver.browser.current_url), driver.browser.current_url
コード例 #10
0
ファイル: test_course.py プロジェクト: yoshoo90/omegaup
def test_create_identities_for_course(driver):
    '''Adding some identities into a course and associating one of them to
    specific user
    '''

    run_id = driver.generate_id()
    course_alias = 'ut_rank_course_%s' % run_id
    school_name = 'ut_rank_school_%s' % run_id
    assignment_alias = 'ut_rank_hw_%s' % run_id
    problem = 'sumas'
    username = '******' % driver.generate_id()
    password = '******'
    driver.register_user(username, password)

    # Admin creates a course with one assignment and one problem, and then
    # creates some identities associated with the course group
    with driver.login_admin():
        create_course(driver, course_alias, school_name)
        add_assignment(driver, assignment_alias)
        add_problem_to_assignment(driver, assignment_alias, problem)
        # The function require the group alias. We are assuming that it is the
        # same as the course alias, since that is the default
        unassociated, associated = util.add_identities_group(
            driver, course_alias)[:2]

    # Unassociated identity joins the course which it was created for and
    # creates a new run
    with driver.login(unassociated.username, unassociated.password):
        enter_course(driver, course_alias, assignment_alias)

        driver.wait.until(
            EC.element_to_be_clickable(
                (By.XPATH, ('//a[contains(text(), "%s")]/parent::div' %
                            problem.title())))).click()

        util.create_run(driver, problem, 'Main.cpp17-gcc')
        driver.update_score_in_course(problem, assignment_alias)

        driver.wait.until(
            EC.element_to_be_clickable(
                (By.CSS_SELECTOR, 'button[data-run-details]'))).click()

        assert (('show-run:')
                in driver.browser.current_url), driver.browser.current_url

    # Registred user associates a new identity
    with driver.login(username, password):
        driver.wait.until(
            EC.element_to_be_clickable(
                (By.CSS_SELECTOR, 'a[data-nav-user]'))).click()
        with driver.page_transition():
            driver.wait.until(
                EC.element_to_be_clickable(
                    (By.CSS_SELECTOR, 'a[data-nav-profile]'))).click()

        with driver.page_transition():
            driver.wait.until(
                EC.element_to_be_clickable(
                    (By.XPATH, ('//a[@href = "/profile/edit/"]')))).click()

        driver.wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 '//input[contains(concat(" ", normalize-space(@class), " "), '
                 '" username-input ")]'))).send_keys(associated.username)
        driver.wait.until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 '//input[contains(concat(" ", normalize-space(@class), " "), '
                 '" password-input ")]'))).send_keys(associated.password)

        driver.wait.until(
            EC.element_to_be_clickable(
                (By.XPATH,
                 '//form[contains(concat(" ", normalize-space(@class), " "), '
                 '" add-identity-form ")]/div/button'))).click()

        associated_identities = driver.browser.find_element_by_xpath(
            '//tr/td[text() = "%s"]' % (associated.username))
        assert associated_identities is not None, 'No identity matches'

    # The new associated identity joins the course
    with driver.login(associated.username, associated.password):
        enter_course(driver, course_alias, assignment_alias)
コード例 #11
0
ファイル: test_course.py プロジェクト: zulygs/omegaup
def test_user_ranking_course(driver):
    '''Creates a course and students to participate make submits to problems'''

    run_id = driver.generate_id()
    course_alias = f'ut_rank_course_{run_id}'
    school_name = f'ut_rank_school_{run_id}'
    assignment_alias = f'ut_rank_hw_{run_id}'
    problem = 'ut_rc_problem_%s' % driver.generate_id()

    _setup_course(driver, course_alias, school_name, assignment_alias, problem)

    with driver.login_user():
        enter_course(driver, course_alias, assignment_alias)
        _click_on_problem(driver, problem)

        util.create_run(driver, problem, 'Main.cpp17-gcc')
        driver.update_score_in_course(problem, assignment_alias)

        # Refresh the current page.
        with driver.page_transition():
            driver.browser.get(driver.browser.current_url.split('#')[0])

        _click_on_problem(driver, problem)

        # When user has tried or solved a problem, feedback popup will be shown
        with util.dismiss_status(driver):
            driver.wait.until(
                EC.element_to_be_clickable(
                    (By.CSS_SELECTOR, '.popup button.close'))).click()
            driver.wait.until(
                EC.invisibility_of_element_located(
                    (By.CSS_SELECTOR, '.popup button.close')))

        _click_on_problem(driver, problem)
        driver.wait.until(
            EC.element_to_be_clickable(
                (By.CSS_SELECTOR, 'button[data-run-details]'))).click()

        assert (('show-run:')
                in driver.browser.current_url), driver.browser.current_url

    update_scoreboard_for_assignment(driver, assignment_alias, course_alias)

    with driver.login_admin():
        enter_course_assignments_page(driver, course_alias)
        with driver.page_transition():
            driver.wait.until(
                EC.element_to_be_clickable(
                    (By.XPATH,
                     '//a[contains(@href, "/assignment/%s/scoreboard/")]' %
                     assignment_alias))).click()

        toggle_contestants_element = driver.wait.until(
            EC.element_to_be_clickable(
                (By.CSS_SELECTOR, 'input.toggle-contestants')))
        for _ in range(10):
            toggle_contestants_element.click()
            if not toggle_contestants_element.is_selected():
                break
        else:
            logging.error('Failed to toggle contestants')

        run_user = driver.browser.find_element_by_xpath(
            '//td[contains(@class, "accepted")]/preceding-sibling::td[@class='
            '"user"]')
        assert run_user.text == driver.user_username, run_user

        url = '/course/{}/assignment/{}/scoreboard'.format(
            course_alias, assignment_alias)

        enter_course_assignments_page(driver, course_alias)
        util.check_scoreboard_events(driver,
                                     assignment_alias,
                                     url,
                                     num_elements=1,
                                     scoreboard='Scoreboard')

        enter_course_assignments_page(driver, course_alias)
        with driver.page_transition():
            driver.wait.until(
                EC.element_to_be_clickable(
                    (By.XPATH, '//a[contains(@href, "/course/%s/edit/")]' %
                     course_alias))).click()

        driver.wait.until(
            EC.element_to_be_clickable((
                By.XPATH,
                '//input[@name = "show-scoreboard"][@value="true"]'))).click()

        driver.browser.find_element_by_css_selector(
            'form[data-course-form]').submit()
        assert (('/course/%s/edit/' % course_alias)
                in driver.browser.current_url), driver.browser.current_url

    with driver.login_user():
        enter_course(driver, course_alias, assignment_alias, first_time=False)

        for _ in range(10):
            driver.wait.until(
                EC.element_to_be_clickable(
                    (By.XPATH, ('//a[contains(@href, "#ranking")]')))).click()
            if driver.browser.current_url.endswith('#ranking'):
                break
        assert (('#ranking')
                in driver.browser.current_url), driver.browser.current_url
コード例 #12
0
def test_create_problem(driver):
    '''Tests creating a public problem and retrieving it.'''

    problem_alias = 'ut_problem_%s' % driver.generate_id()
    create_problem(driver, problem_alias)

    with driver.login_user():
        driver.wait.until(EC.element_to_be_clickable(
            (By.ID, 'nav-problems'))).click()
        with driver.page_transition():
            driver.wait.until(
                EC.element_to_be_clickable(
                    (By.XPATH, ('//li[@id = "nav-problems"]'
                                '//a[@href = "/problem/"]')))).click()

        search_box_element = driver.wait.until(
            EC.visibility_of_element_located((By.ID, 'problem-search-box')))
        search_box_element.send_keys(problem_alias)
        with driver.page_transition():
            search_box_element.submit()

        driver.wait.until(
            EC.element_to_be_clickable(
                (By.XPATH, '//a[text() = "%s"]' % problem_alias))).click()
        assert (problem_alias in driver.browser.find_element_by_xpath(
            '//h1[@class="title"]').get_attribute('innerText'))

        runs_before_submit = driver.browser.find_elements_by_xpath(
            '//td[@class="status"]')

        filename = 'Main.java'
        util.create_run(driver, problem_alias, filename)

        runs_after_submit = driver.browser.find_elements_by_xpath(
            '//td[@class="status"]')

        assert len(runs_before_submit) + 1 == len(runs_after_submit)

        driver.wait.until(
            EC.element_to_be_clickable(
                (By.XPATH, '//button[contains(@class, "details")]'))).click()

        driver.wait.until(
            EC.visibility_of_element_located(
                (By.XPATH, '//form[@class="run-details-view"]')))

        textarea = driver.browser.find_element_by_xpath(
            '//form[@class="run-details-view"]//div[@class="CodeMirror-code"]')

        assert textarea.text is not None

        resource_path = os.path.join(util.OMEGAUP_ROOT,
                                     'frontend/tests/resources', filename)
        # The text of the CodeMirror editor contains the line number.
        # Non-exact match is needed.
        with open(resource_path, 'r') as f:
            for row in f.read().splitlines():
                if row is not None:
                    assert (row in textarea.text), row

        driver.browser.find_element_by_id('overlay').click()
コード例 #13
0
ファイル: test_smoke.py プロジェクト: categulario/omegaup
def test_create_problem(driver):
    '''Tests creating a public problem and retrieving it.'''

    problem_alias = 'unittest_problem_%s' % driver.generate_id()
    create_problem(driver, problem_alias)

    with driver.login_user():
        driver.wait.until(
            EC.element_to_be_clickable(
                (By.ID, 'nav-problems'))).click()
        with driver.page_transition():
            driver.wait.until(
                EC.element_to_be_clickable(
                    (By.XPATH,
                     ('//li[@id = "nav-problems"]'
                      '//a[@href = "/problem/"]')))).click()

        search_box_element = driver.wait.until(
            EC.visibility_of_element_located(
                (By.ID, 'problem-search-box')))
        search_box_element.send_keys(problem_alias)
        with driver.page_transition():
            search_box_element.submit()

        driver.wait.until(
            EC.element_to_be_clickable(
                (By.XPATH,
                 '//a[text() = "%s"]' % problem_alias))).click()
        assert (problem_alias in driver.browser.find_element_by_xpath(
            '//h1[@class="title"]').get_attribute('innerText'))

        runs_before_submit = driver.browser.find_elements_by_xpath(
            '//td[@class="status"]')

        filename = 'Main.java'
        util.create_run(driver, problem_alias, filename)

        runs_after_submit = driver.browser.find_elements_by_xpath(
            '//td[@class="status"]')

        assert len(runs_before_submit) + 1 == len(runs_after_submit)

        driver.wait.until(
            EC.element_to_be_clickable(
                (By.XPATH,
                 '//button[contains(@class, "details")]'))).click()

        driver.wait.until(
            EC.visibility_of_element_located(
                (By.XPATH, '//form[@class="run-details-view"]')))

        textarea = driver.browser.find_element_by_xpath(
            '//form[@class="run-details-view"]//div[@class="CodeMirror-code"]')

        assert textarea.text is not None

        resource_path = os.path.join(util.OMEGAUP_ROOT,
                                     'frontend/tests/resources', filename)
        # The text of the CodeMirror editor contains the line number.
        # Non-exact match is needed.
        with open(resource_path, 'r') as f:
            for row in f.read().splitlines():
                if row is not None:
                    assert (row in textarea.text), row

        driver.browser.find_element_by_id('overlay').click()