Esempio n. 1
0
def get_index(name):
    page_name_css = 'section[data-type="HTMLModule"]'
    all_pages = world.css_find(page_name_css)
    for i in range(len(all_pages)):
        if world.css_html(page_name_css, index=i) == '\n    {name}\n'.format(name=name):
            return i
    return -1
Esempio n. 2
0
def get_index(file_name):
    names_css = 'td.name-col > a.filename'
    all_names = world.css_find(names_css)
    for i in range(len(all_names)):
        if file_name == world.css_html(names_css, index=i):
            return i
    return -1
Esempio n. 3
0
def no_duplicate(_step, file_name):
    all_names = world.css_find(ASSET_NAMES_CSS)
    only_one = False
    for i in range(len(all_names)):
        if file_name == world.css_html(ASSET_NAMES_CSS, index=i):
            only_one = not only_one
    assert only_one
Esempio n. 4
0
def see_a_multi_step_component(step, category):

    # Wait for all components to finish rendering
    selector = 'li.studio-xblock-wrapper div.xblock-student_view'
    world.wait_for(lambda _: len(world.css_find(selector)) == len(step.hashes))

    for idx, step_hash in enumerate(step.hashes):

        if category == 'HTML':
            html_matcher = {
                'Text':
                    '\n    \n',
                'Announcement':
                    '<p> Words of encouragement! This is a short note that most students will read. </p>',
                'Zooming Image':
                    '<h2>ZOOMING DIAGRAMS</h2>',
                'E-text Written in LaTeX':
                    '<h2>Example: E-text page</h2>',
                'Raw HTML':
                    '<p>This template is similar to the Text template. The only difference is',
            }
            actual_html = world.css_html(selector, index=idx)
            assert_in(html_matcher[step_hash['Component']], actual_html)
        else:
            actual_text = world.css_text(selector, index=idx)
            assert_in(step_hash['Component'].upper(), actual_text)
Esempio n. 5
0
def no_duplicate(_step, file_name):
    names_css = 'td.name-col > a.filename'
    all_names = world.css_find(names_css)
    only_one = False
    for i in range(len(all_names)):
        if file_name == world.css_html(names_css, index=i):
            only_one = not only_one
    assert only_one
Esempio n. 6
0
def i_click_on_error_dialog(step):
    world.click_link_by_text('Correct failed component')
    assert_true(world.css_html("span.inline-error").startswith("Problem i4x://MITx/999/problem"))
    course_key = SlashSeparatedCourseKey("MITx", "999", "Robot_Super_Course")
    # we don't know the actual ID of the vertical. So just check that we did go to a
    # vertical page in the course (there should only be one).
    vertical_usage_key = course_key.make_usage_key("vertical", "")
    vertical_url = reverse_usage_url('unit_handler', vertical_usage_key)
    assert_equal(1, world.browser.url.count(vertical_url))
def verify_report_is_generated(report_name_substring):
    # Need to reload the page to see the reports table updated
    reload_the_page(step)
    world.wait_for_visible("#report-downloads-table")
    # Find table and assert a .csv file is present
    quoted_id = http.urlquote(world.course_key).replace("/", "_")
    expected_file_regexp = quoted_id + "_" + report_name_substring + "_\d{4}-\d{2}-\d{2}-\d{4}\.csv"
    assert_regexp_matches(
        world.css_html("#report-downloads-table"), expected_file_regexp, msg="Expected report filename was not found."
    )
Esempio n. 8
0
def i_click_on_error_dialog(step):
    world.click_link_by_text('Correct failed component')

    problem_string = unicode(world.scenario_dict['COURSE'].id.make_usage_key("problem", 'ignore'))
    problem_string = u"Problem {}".format(problem_string[:problem_string.rfind('ignore')])
    assert_true(
        world.css_html("span.inline-error").startswith(problem_string),
        u"{} does not start with {}".format(
            world.css_html("span.inline-error"), problem_string
        ))
    # we don't know the actual ID of the vertical. So just check that we did go to a
    # vertical page in the course (there should only be one).
    vertical_usage_key = world.scenario_dict['COURSE'].id.make_usage_key("vertical", None)
    vertical_url = reverse_usage_url('container_handler', vertical_usage_key)
    # Remove the trailing "/None" from the URL - we don't know the course ID, so we just want to
    # check that we visited a vertical URL.
    if vertical_url.endswith("/None"):
        vertical_url = vertical_url[:-5]
    assert_equal(1, world.browser.url.count(vertical_url))
Esempio n. 9
0
def find_grade_report_csv_link(step):  # pylint: disable=unused-argument
    # Need to reload the page to see the grades download table
    reload_the_page(step)
    world.wait_for_visible('#report-downloads-table')
    # Find table and assert a .csv file is present
    expected_file_regexp = 'edx_999_Test_Course_grade_report_\d{4}-\d{2}-\d{2}-\d{4}\.csv'
    assert_regexp_matches(
        world.css_html('#report-downloads-table'), expected_file_regexp,
        msg="Expected grade report filename was not found."
    )
Esempio n. 10
0
def find_grade_report_csv_link(step):  # pylint: disable=unused-argument
    # Need to reload the page to see the grades download table
    reload_the_page(step)
    world.wait_for_visible('#report-downloads-table')
    # Find table and assert a .csv file is present
    quoted_id = http.urlquote(world.course_key).replace('/', '_')
    expected_file_regexp = quoted_id + '_grade_report_\d{4}-\d{2}-\d{2}-\d{4}\.csv'
    assert_regexp_matches(
        world.css_html('#report-downloads-table'), expected_file_regexp,
        msg="Expected grade report filename was not found."
    )
Esempio n. 11
0
def i_click_on_error_dialog(step):
    world.css_click("button.action-primary")

    problem_string = unicode(world.scenario_dict['COURSE'].id.make_usage_key("problem", 'ignore'))
    problem_string = u"Problem {}".format(problem_string[:problem_string.rfind('ignore')])
    css_selector = "span.inline-error"
    world.wait_for_visible(css_selector)
    assert_true(
        world.css_html(css_selector).startswith(problem_string),
        u"{} does not start with {}".format(
            world.css_html(css_selector), problem_string
        ))
    # we don't know the actual ID of the vertical. So just check that we did go to a
    # vertical page in the course (there should only be one).
    vertical_usage_key = world.scenario_dict['COURSE'].id.make_usage_key("vertical", "test")
    vertical_url = reverse_usage_url('container_handler', vertical_usage_key)
    # Remove the trailing "/None" from the URL - we don't know the course ID, so we just want to
    # check that we visited a vertical URL.
    if vertical_url.endswith("/test") or vertical_url.endswith("@test"):
        vertical_url = vertical_url[:-5]
    assert_equal(1, world.browser.url.count(vertical_url))
Esempio n. 12
0
def i_click_on_error_dialog(step):
    world.click_link_by_text('Correct failed component')
    assert_true(world.css_html("span.inline-error").startswith("Problem i4x://MITx/999/problem"))
    course_key = SlashSeparatedCourseKey("MITx", "999", "Robot_Super_Course")
    # we don't know the actual ID of the vertical. So just check that we did go to a
    # vertical page in the course (there should only be one).
    vertical_usage_key = course_key.make_usage_key("vertical", None)
    vertical_url = reverse_usage_url('container_handler', vertical_usage_key)
    # Remove the trailing "/None" from the URL - we don't know the course ID, so we just want to
    # check that we visited a vertical URL.
    if vertical_url.endswith("/None"):
        vertical_url = vertical_url[:-5]
    assert_equal(1, world.browser.url.count(vertical_url))
Esempio n. 13
0
def see_a_multi_step_component(step, category):

    # Wait for all components to finish rendering
    selector = "li.component section.xblock-student_view"
    world.wait_for(lambda _: len(world.css_find(selector)) == len(step.hashes))

    for idx, step_hash in enumerate(step.hashes):

        if category == "HTML":
            html_matcher = {
                "Text": "\n    \n",
                "Announcement": "<p> Words of encouragement! This is a short note that most students will read. </p>",
                "E-text Written in LaTeX": "<h2>Example: E-text page</h2>",
            }
            actual_html = world.css_html(selector, index=idx)
            assert_in(html_matcher[step_hash["Component"]], actual_html)
        else:
            actual_text = world.css_text(selector, index=idx)
            assert_in(step_hash["Component"].upper(), actual_text)
Esempio n. 14
0
def see_a_multi_step_component(step, category):

    # Wait for all components to finish rendering
    selector = 'li.studio-xblock-wrapper div.xblock-student_view'
    world.wait_for(lambda _: len(world.css_find(selector)) == len(step.hashes))

    for idx, step_hash in enumerate(step.hashes):
        if category == 'HTML':
            html_matcher = {
                'Text': '\n    \n',
                'Announcement': '<h3 class="hd hd-2">Announcement Date</h3>',
                'Zooming Image Tool': '<h3 class="hd hd-2">Zooming Image Tool</h3>',
                'E-text Written in LaTeX': '<h3 class="hd hd-2">Example: E-text page</h3>',
                'Raw HTML': '<p>This template is similar to the Text template. The only difference is',
            }
            actual_html = world.css_html(selector, index=idx)
            assert_in(html_matcher[step_hash['Component']].strip(), actual_html.strip())
        else:
            actual_text = world.css_text(selector, index=idx)
            assert_in(step_hash['Component'], actual_text)
Esempio n. 15
0
def see_a_multi_step_component(step, category):

    # Wait for all components to finish rendering
    selector = 'li.component section.xmodule_display'
    world.wait_for(lambda _: len(world.css_find(selector)) == len(step.hashes))

    for idx, step_hash in enumerate(step.hashes):

        if category == 'HTML':
            html_matcher = {
                'Text':
                    '\n    \n',
                'Announcement':
                    '<p> Words of encouragement! This is a short note that most students will read. </p>',
                'E-text Written in LaTeX':
                    '<h2>Example: E-text page</h2>',
            }
            actual_html = world.css_html(selector, index=idx)
            assert_in(html_matcher[step_hash['Component']], actual_html)
        else:
            actual_text = world.css_text(selector, index=idx)
            assert_in(step_hash['Component'].upper(), actual_text)
Esempio n. 16
0
def check_handout_image_link(_step, image_file):
    handout_css = 'div.handouts-content'
    handout_html = world.css_html(handout_css)
    asset_key = world.scenario_dict['COURSE'].id.make_asset_key(asset_type='asset', path=image_file)
    assert_in(unicode(asset_key), handout_html)
Esempio n. 17
0
def i_click_on_error_dialog(step):
    world.click_link_by_text('Correct failed component')
    assert_true(world.css_html("span.inline-error").startswith("Problem i4x://MITx/999/problem"))
    assert_equal(1, world.browser.url.count("unit/MITx.999.Robot_Super_Course/branch/draft/block/vertical"))
def check_date(_step, date):
    date_css = "span.date-display"
    assert date == world.css_html(date_css)
Esempio n. 19
0
def check_component_display_name(step, display_name):
    # The display name for the unit uses the same structure, must differentiate by level-element.
    label = world.css_html(
        "section.level-element>header>div>div>span.xblock-display-name")
    assert_equal(display_name, label)
Esempio n. 20
0
def check_component_display_name(step, display_name):
    # The display name for the unit uses the same structure, must differentiate by level-element.
    label = world.css_html("section.level-element>header>div>div>span.xblock-display-name")
    assert_equal(display_name, label)
Esempio n. 21
0
def get_index(file_name):
    all_names = world.css_find(ASSET_NAMES_CSS)
    for i in range(len(all_names)):
        if file_name == world.css_html(ASSET_NAMES_CSS, index=i):
            return i
    return -1
Esempio n. 22
0
def confirm_change(_step):
    range_css = '.range'
    all_ranges = world.css_find(range_css)
    for i in range(len(all_ranges)):
        assert_not_equal(world.css_html(range_css, index=i), '0-50')
Esempio n. 23
0
def see_a_static_page_named_foo(step, name):
    pages_css = 'section.xmodule_StaticTabModule'
    page_name_html = world.css_html(pages_css)
    assert_equal(page_name_html, '\n    {name}\n'.format(name=name))
Esempio n. 24
0
def see_a_static_page_named_foo(step, name):
    pages_css = 'div.xmodule_StaticTabModule'
    page_name_html = world.css_html(pages_css)
    assert_equal(page_name_html.strip(), name)
Esempio n. 25
0
def confirm_change(step):
    range_css = ".range"
    all_ranges = world.css_find(range_css)
    for i in range(len(all_ranges)):
        assert_not_equal(world.css_html(range_css, index=i), "0-50")
def check_handout(_step, handout):
    handout_css = 'div.handouts-content'
    assert_in(handout, world.css_html(handout_css))
Esempio n. 27
0
def check_handout_image_link(_step, image_file):
    handout_css = 'div.handouts-content'
    handout_html = world.css_html(handout_css)
    asset_key = world.scenario_dict['COURSE'].id.make_asset_key(
        asset_type='asset', path=image_file)
    assert_in(unicode(asset_key), handout_html)
Esempio n. 28
0
def check_date(_step, date):
    date_css = 'span.date-display'
    assert date == world.css_html(date_css)
Esempio n. 29
0
def check_date(_step, date):
    date_css = 'span.date-display'
    assert_in(date, world.css_html(date_css))
Esempio n. 30
0
def confirm_change(step):
    range_css = '.range'
    all_ranges = world.css_find(range_css)
    for i in range(len(all_ranges)):
        assert world.css_html(range_css, index=i) != '0-50'
Esempio n. 31
0
def check_handout(_step, handout):
    handout_css = 'div.handouts-content'
    assert_in(handout, world.css_html(handout_css))
Esempio n. 32
0
def start_playing_video_from_n_seconds(_step, position):
    world.wait_for(
        func=lambda _: world.css_html('.vidtime')[:4] == position.strip(),
        timeout=5
    )
Esempio n. 33
0
def get_index(file_name):
    all_names = world.css_find(ASSET_NAMES_CSS)
    for i in range(len(all_names)):
        if file_name == world.css_html(ASSET_NAMES_CSS, index=i):
            return i
    return -1
Esempio n. 34
0
def see_a_static_page_named_foo(step, name):
    pages_css = 'section.xmodule_StaticTabModule'
    page_name_html = world.css_html(pages_css)
    assert_equal(page_name_html, '\n    {name}\n'.format(name=name))
Esempio n. 35
0
def confirm_change(step):
    range_css = '.range'
    all_ranges = world.css_find(range_css)
    for i in range(len(all_ranges)):
        assert world.css_html(range_css, index=i) != '0-50'
def check_handout(_step, handout):
    handout_css = "div.handouts-content"
    assert handout in world.css_html(handout_css)
Esempio n. 37
0
def see_a_static_page_named_foo(step, name):
    pages_css = 'div.xmodule_StaticTabModule'
    page_name_html = world.css_html(pages_css)
    assert_equal(page_name_html.strip(), name)
Esempio n. 38
0
def start_playing_video_from_n_seconds(_step, position):
    world.wait_for(
        func=lambda _: world.css_html('.vidtime')[:4] == position.strip(),
        timeout=5)