Exemplo n.º 1
0
def incorrect_lti_is_rendered(_step):
    assert world.is_css_present('iframe', wait_time=2)
    assert not world.is_css_present('.link_lti_new_window', wait_time=0)
    assert not world.is_css_present('.error_message', wait_time=0)

    # inside iframe test content is presented
    check_lti_iframe_content("Wrong LTI signature")
Exemplo n.º 2
0
def view_lti_permission_alert(_step):
    assert not world.is_css_present('iframe', wait_time=2)
    assert world.is_css_present('.link_lti_new_window', wait_time=0)
    assert not world.is_css_present('.error_message', wait_time=0)
    world.css_find('.link_lti_new_window').first.click()
    alert = world.browser.get_alert()
    assert alert is not None
    assert len(world.browser.windows) == 1
Exemplo n.º 3
0
def set_captions_visibility_state(_step, captions_state):
    SELECTOR = ".closed .subtitles"
    if captions_state == "closed":
        if not world.is_css_present(SELECTOR):
            world.browser.find_by_css(".hide-subtitles").click()
    else:
        if world.is_css_present(SELECTOR):
            world.browser.find_by_css(".hide-subtitles").click()
Exemplo n.º 4
0
def set_captions_visibility_state(_step, captions_state):
    SELECTOR = ".closed .subtitles"
    world.wait_for_visible(".hide-subtitles")
    if captions_state == "closed":
        if not world.is_css_present(SELECTOR):
            world.css_find(".hide-subtitles").click()
    else:
        if world.is_css_present(SELECTOR):
            world.css_find(".hide-subtitles").click()
Exemplo n.º 5
0
def set_captions_visibility_state(_step, captions_state):
    SELECTOR = '.closed .subtitles'
    world.wait_for_visible('.hide-subtitles')
    if captions_state == 'closed':
        if not world.is_css_present(SELECTOR):
            world.css_find('.hide-subtitles').click()
    else:
        if world.is_css_present(SELECTOR):
            world.css_find('.hide-subtitles').click()
Exemplo n.º 6
0
def lti_is_not_rendered(_step):
    # error is shown
    assert world.is_css_present('.error_message', wait_time=0)

    # iframe is not presented
    assert not world.is_css_present('iframe', wait_time=0)

    # link is not presented
    assert not world.is_css_present('.link_lti_new_window', wait_time=0)
Exemplo n.º 7
0
def lti_is_rendered_iframe(_step):
    world.wait_for_present('iframe')  # pylint: disable=no-member
    assert world.is_css_present('iframe', wait_time=2)  # pylint: disable=no-member
    assert not world.is_css_present('.link_lti_new_window', wait_time=0)  # pylint: disable=no-member
    assert not world.is_css_present('.error_message', wait_time=0)  # pylint: disable=no-member

    # iframe is visible
    assert world.css_visible('iframe')  # pylint: disable=no-member
    check_lti_iframe_content("This is LTI tool. Success.")
Exemplo n.º 8
0
def check_role(_step, role):
    world.is_css_present("iframe")
    location = world.scenario_dict["LTI"].location.html_id()
    iframe_name = "ltiFrame-" + location
    with world.browser.get_iframe(iframe_name) as iframe:
        expected_role = "Role: " + role
        role = world.retry_on_exception(
            lambda: iframe.find_by_tag("h5").first.value, max_attempts=5, ignored_exceptions=ElementDoesNotExist
        )
        assert_equal(expected_role, role)
Exemplo n.º 9
0
def i_unenroll_from_that_course(_step, course):
    more_actions_dropdown_link_selector = '[id*=actions-dropdown-link-0]'
    assert world.is_css_present(more_actions_dropdown_link_selector)
    world.css_click(more_actions_dropdown_link_selector)

    unregister_css = 'li.actions-item a.action-unenroll[data-course-number*="{course_number}"][href*=unenroll-modal]'.format(course_number=course)
    assert world.is_css_present(unregister_css)
    world.css_click(unregister_css)

    button_css = 'section#unenroll-modal input[value="Unenroll"]'
    assert world.is_css_present(button_css)
    world.css_click(button_css)
Exemplo n.º 10
0
def verify_high_level_source_links(step, visible):
    if visible:
        assert_true(world.is_css_present('.launch-latex-compiler'),
                    msg="Expected to find the latex button but it is not present.")
    else:
        assert_true(world.is_css_not_present('.launch-latex-compiler'),
                    msg="Expected not to find the latex button but it is present.")

    world.cancel_component(step)
    if visible:
        assert_true(world.is_css_present('.upload-button'),
                    msg="Expected to find the upload button but it is not present.")
    else:
        assert_true(world.is_css_not_present('.upload-button'),
                    msg="Expected not to find the upload button but it is present.")
Exemplo n.º 11
0
def css_value(css_selector, index=0, max_attempts=5):

    # Wait for the css selector to appear
    if world.is_css_present(css_selector):
        return world.retry_on_exception(lambda: world.browser.find_by_css(css_selector)[index].value, max_attempts=max_attempts)
    else:
        return ""
Exemplo n.º 12
0
def marked_as_admin(_step, name, not_marked_admin):
    flag_css = '.user-item[data-email="{name}@edx.org"] .flag-role.flag-role-admin'.format(
        name=name)
    if not_marked_admin:
        assert world.is_css_not_present(flag_css)
    else:
        assert world.is_css_present(flag_css)
Exemplo n.º 13
0
def marked_as_admin(_step, name, inverted):
    flag_css = '.user-item[data-email="{email}"] .flag-role.flag-role-admin'.format(
        email=name+EMAIL_EXTENSION)
    if inverted:
        assert world.is_css_not_present(flag_css)
    else:
        assert world.is_css_present(flag_css)
Exemplo n.º 14
0
def other_user_login(step, name):
    step.given('I log out')
    world.visit('/')

    signin_css = 'a.action-signin'
    world.is_css_present(signin_css)
    world.css_click(signin_css)

    def fill_login_form():
        login_form = world.browser.find_by_css('form#login_form')
        login_form.find_by_name('email').fill(name + '@edx.org')
        login_form.find_by_name('password').fill("test")
        login_form.find_by_name('submit').click()
    world.retry_on_exception(fill_login_form)
    assert world.is_css_present('.new-course-button')
    world.scenario_dict['USER'] = get_user(name + '@edx.org')
Exemplo n.º 15
0
def inputfield(problem_type, choice=None, input_num=1):
    """ Return the css selector for `problem_type`.
    For example, if problem_type is 'string', return
    the text field for the string problem in the test course.

    `choice` is the name of the checkbox input in a group
    of checkboxes. """

    sel = ("input#input_i4x-edx-model_course-problem-%s_2_%s" %
           (problem_type.replace(" ", "_"), str(input_num)))

   # this is necessary due to naming requirement for this problem type
    if problem_type in ("radio_text", "checkbox_text"):
        sel = "input#i4x-edx-model_course-problem-{0}_2_{1}".format(
            problem_type.replace(" ", "_"), str(input_num)
        )

    if choice is not None:
        base = "_choice_" if problem_type == "multiple choice" else "_"
        sel = sel + base + str(choice)

    # If the input element doesn't exist, fail immediately
    assert world.is_css_present(sel)

    # Retrieve the input element
    return sel
Exemplo n.º 16
0
def i_visit_the_studio_homepage(_step):
    # To make this go to port 8001, put
    # LETTUCE_SERVER_PORT = 8001
    # in your settings.py file.
    world.visit('/')
    signin_css = 'a.action-signin'
    assert world.is_css_present(signin_css)
Exemplo n.º 17
0
def select_verified_track_upgrade(step):
    select_contribution(32)
    world.wait_for_ajax_complete()
    btn_css = 'input[value="Upgrade Your Registration"]'
    world.css_click(btn_css)
    # TODO: might want to change this depending on the changes for upgrade
    assert world.is_css_present('section.progress')
Exemplo n.º 18
0
def register():
    url = 'courses/{org}/{number}/{name}/about'.format(
        org='edx', number='999', name='Certificates')
    world.browser.visit(django_url(url))

    world.css_click('section.intro a.register')
    assert world.is_css_present('section.wrapper h3.title')
Exemplo n.º 19
0
def css_text(css_selector):

    # Wait for the css selector to appear
    if world.is_css_present(css_selector):
        return world.browser.find_by_css(css_selector).first.text
    else:
        return ""
Exemplo n.º 20
0
def i_verify_all_the_content_of_each_course(step):
    all_possible_courses = get_courses()
    logger.debug('Courses found:')
    for c in all_possible_courses:
        logger.debug(c.id)
    ids = [c.id for c in all_possible_courses]

    # Get a list of all the registered courses
    registered_courses = world.browser.find_by_css('article.my-course')
    if len(all_possible_courses) < len(registered_courses):
        assert False, "user is registered for more courses than are uniquely posssible"
    else:
        pass

    for test_course in registered_courses:
        test_course.css_click('a')
        check_for_errors()

        # Get the course. E.g. 'MITx/6.002x/2012_Fall'
        current_course = sub('/info', '', sub('.*/courses/', '', world.browser.url))
        validate_course(current_course, ids)

        world.click_link('Courseware')
        assert world.is_css_present('accordion')
        check_for_errors()
        browse_course(current_course)

        # clicking the user link gets you back to the user's home page
        world.css_click('.user-link')
        check_for_errors()
Exemplo n.º 21
0
def see_a_problem_component(step, category):
    component_css = "section.xmodule_CapaModule"
    assert_true(world.is_css_present(component_css), "No problem was added to the unit.")

    problem_css = "li.component section.xblock-student_view"
    actual_text = world.css_text(problem_css)
    assert_in(category.upper(), actual_text)
Exemplo n.º 22
0
def other_user_login(_step, name):
    world.browser.cookies.delete()
    world.visit('/')

    signin_css = 'a.action-signin'
    world.is_css_present(signin_css)
    world.css_click(signin_css)

    def fill_login_form():
        login_form = world.browser.find_by_css('form#login_form')
        login_form.find_by_name('email').fill(name + EMAIL_EXTENSION)
        login_form.find_by_name('password').fill(PASSWORD)
        login_form.find_by_name('submit').click()
    world.retry_on_exception(fill_login_form)
    assert_true(world.is_css_present('.new-course-button'))
    world.scenario_dict['USER'] = get_user_by_email(name + EMAIL_EXTENSION)
Exemplo n.º 23
0
def assert_answer_mark(_step, problem_type, isnt_marked, correctness):
    """
    Assert that the expected answer mark is visible
    for a given problem type.

    *problem_type* is a string identifying the type of problem (e.g. 'drop down')
    *correctness* is in ['correct', 'incorrect', 'unanswered']
    """
    # Determine which selector(s) to look for based on correctness
    assert(correctness in ['correct', 'incorrect', 'unanswered'])
    assert(problem_type in PROBLEM_DICT)

    # At least one of the correct selectors should be present
    for sel in PROBLEM_DICT[problem_type][correctness]:
        if bool(isnt_marked):
            world.wait_for(lambda _: world.is_css_not_present(sel))  # pylint: disable=cell-var-from-loop
            has_expected = world.is_css_not_present(sel)
        else:
            world.css_find(sel)  # css_find includes a wait_for pattern
            has_expected = world.is_css_present(sel)

        # As soon as we find the selector, break out of the loop
        if has_expected:
            break

    # Expect that we found the expected selector
    assert(has_expected)
Exemplo n.º 24
0
def i_register_to_audit_the_course(_step):
    url = django_url('courses/%s/about' % world.scenario_dict['COURSE'].id.to_deprecated_string())
    world.browser.visit(url)
    world.css_click('section.intro a.register')
    audit_button = world.browser.find_by_name("audit_mode")
    audit_button.click()
    assert world.is_css_present('section.container.dashboard')
Exemplo n.º 25
0
def select_the_verified_track(step):
    create_cert_course()
    register()
    select_contribution(32)
    btn_css = 'input[value="Select Certificate"]'
    world.css_click(btn_css)
    assert world.is_css_present('section.progress')
Exemplo n.º 26
0
def i_see_status_message(_step, status):
    assert not world.css_visible(SELECTORS['error_bar'])
    assert world.css_has_text(SELECTORS['status_bar'], STATUSES[status])

    DOWNLOAD_BUTTON = TRANSCRIPTS_BUTTONS["download_to_edit"][0]
    if world.is_css_present(DOWNLOAD_BUTTON, wait_time=1) and not world.css_find(DOWNLOAD_BUTTON)[0].has_class('is-disabled'):
        assert _transcripts_are_downloaded()
Exemplo n.º 27
0
def i_register_for_the_course(_step, course):
    cleaned_name = world.scenario_dict['COURSE'].display_name.replace(' ', '_')
    url = django_url('courses/%s/%s/%s/about' % (world.scenario_dict['COURSE'].org, course, cleaned_name))
    world.browser.visit(url)
    world.css_click('section.intro a.register')

    assert world.is_css_present('section.container.dashboard')
def create_component_instance(step, category, component_type=None, is_advanced=False):
    """
    Create a new component in a Unit.

    Parameters
    ----------
    category: component type (discussion, html, problem, video)
    component_type: for components with multiple templates, the link text in the menu
    is_advanced: for html and problem, is the desired component under the
                 advanced menu
    """
    assert_in(category, ['problem', 'html', 'video', 'discussion'])

    component_button_css = '.large-{}-icon'.format(category.lower())
    world.css_click(component_button_css)

    if category in ('problem', 'html'):
        world.wait_for_invisible(component_button_css)
        click_component_from_menu(category, component_type, is_advanced)

    if category == 'problem':
        expected_css = 'section.xmodule_CapaModule'
    else:
        expected_css = 'section.xmodule_{}Module'.format(category.title())

    assert_true(world.is_css_present(expected_css))
Exemplo n.º 29
0
def see_a_single_step_component(step):
    for step_hash in step.hashes:
        component = step_hash['Component']
        assert_in(component, ['Discussion', 'Video'])
        component_css = 'div.xmodule_{}Module'.format(component)
        assert_true(world.is_css_present(component_css),
                    "{} couldn't be found".format(component))
Exemplo n.º 30
0
def inputfield(course, problem_type, choice=None, input_num=1):
    """ Return the css selector for `problem_type`.
    For example, if problem_type is 'string', return
    the text field for the string problem in the test course.

    `choice` is the name of the checkbox input in a group
    of checkboxes. """

    section_loc = section_location(course)

    ptype = problem_type.replace(" ", "_")
    # this is necessary due to naming requirement for this problem type
    if problem_type in ("radio_text", "checkbox_text"):
        selector_template = "input#{}_2_{input}"
    else:
        selector_template = "input#input_{}_2_{input}"

    sel = selector_template.format(
        section_loc.course_key.make_usage_key('problem', ptype).html_id(),
        input=input_num,
    )

    if choice is not None:
        base = "_choice_" if problem_type == "multiple choice" else "_"
        sel = sel + base + str(choice)

    # If the input element doesn't exist, fail immediately
    assert world.is_css_present(sel)

    # Retrieve the input element
    return sel
Exemplo n.º 31
0
def css_text(css_selector):

    # Wait for the css selector to appear
    if world.is_css_present(css_selector):
        try:
            return world.browser.find_by_css(css_selector).first.text
        except StaleElementReferenceException:
            # The DOM was still redrawing. Wait a second and try again.
            world.wait(1)
            return world.browser.find_by_css(css_selector).first.text
    else:
        return ""
Exemplo n.º 32
0
def i_see_a_release_date_for_my_section(step):
    import re

    css = 'span.published-status'
    assert world.is_css_present(css)
    status_text = world.browser.find_by_css(css).text

    # e.g. 11/06/2012 at 16:25
    msg = 'Will Release:'
    date_regex = '[01][0-9]\/[0-3][0-9]\/[12][0-9][0-9][0-9]'
    time_regex = '[0-2][0-9]:[0-5][0-9]'
    match_string = '%s %s at %s' % (msg, date_regex, time_regex)
    assert re.match(match_string, status_text)
Exemplo n.º 33
0
def i_register_to_audit_the_course(_step):
    url = django_url('courses/%s/about' %
                     world.scenario_dict['COURSE'].id.to_deprecated_string())
    world.browser.visit(url)
    world.css_click('section.intro a.register')
    # the below button has a race condition. When the page first loads
    # some animation needs to complete before this button is in a stable
    # position. TODO: implement this without a sleep.
    time.sleep(2)
    audit_button = world.browser.find_by_name("audit_mode")
    audit_button.click()
    time.sleep(1)
    assert world.is_css_present('section.container.dashboard')
Exemplo n.º 34
0
def i_register_to_audit_the_course(_step):
    url = django_url('courses/%s/about' %
                     world.scenario_dict['COURSE'].id.to_deprecated_string())
    world.browser.visit(url)
    world.css_click('.intro a.register')
    # When the page first loads some animation needs to
    # complete before this button is in a stable location
    world.retry_on_exception(
        lambda: world.browser.find_by_name("honor_mode").click(),
        max_attempts=10,
        ignored_exceptions=AttributeError)
    time.sleep(1)
    assert world.is_css_present('.container.dashboard')
Exemplo n.º 35
0
def delete_components(step, number):
    world.wait_for_xmodule()
    delete_btn_css = 'a.delete-button'
    prompt_css = 'div#prompt-warning'
    btn_css = '{} a.button.action-primary'.format(prompt_css)
    saving_mini_css = 'div#page-notification .wrapper-notification-mini'
    for _ in range(int(number)):
        world.css_click(delete_btn_css)
        assert_true(
            world.is_css_present('{}.is-shown'.format(prompt_css)),
            msg='Waiting for the confirmation prompt to be shown')

        # Pressing the button via css was not working reliably for the last component
        # when run in Chrome.
        if world.browser.driver_name is 'Chrome':
            world.browser.execute_script("$('{}').click()".format(btn_css))
        else:
            world.css_click(btn_css)

        # Wait for the saving notification to pop up then disappear
        if world.is_css_present('{}.is-shown'.format(saving_mini_css)):
            world.css_find('{}.is-hiding'.format(saving_mini_css))
Exemplo n.º 36
0
def create_a_course():
    c = world.CourseFactory.create(org='MITx', course='999', display_name='Robot Super Course')

    # Add the user to the instructor group of the course
    # so they will have the permissions to see it in studio
    g = world.GroupFactory.create(name='instructor_MITx/999/Robot_Super_Course')
    u = get_user_by_email('*****@*****.**')
    u.groups.add(g)
    u.save()
    world.browser.reload()

    course_link_css = 'span.class-name'
    world.css_click(course_link_css)
    course_title_css = 'span.course-title'
    assert_true(world.is_css_present(course_title_css))
Exemplo n.º 37
0
def create_a_course():
    course = world.CourseFactory.create(org='MITx', course='999', display_name='Robot Super Course')
    world.scenario_dict['COURSE'] = course

    user = world.scenario_dict.get("USER")
    if not user:
        user = get_user('*****@*****.**')

    add_course_author(user, course)

    # Navigate to the studio dashboard
    world.visit('/')
    course_link_css = 'a.course-link'
    world.css_click(course_link_css)
    course_title_css = 'span.course-title'
    assert_true(world.is_css_present(course_title_css))
Exemplo n.º 38
0
def create_unit_from_course_outline():
    """
    Expands the section and clicks on the New Unit link.
    The end result is the page where the user is editing the new unit.
    """
    css_selectors = [
        '.outline-subsection .expand-collapse', '.outline-subsection .button-new'
    ]
    for selector in css_selectors:
        world.css_click(selector)

    world.wait_for_mathjax()
    world.wait_for_xmodule()
    world.wait_for_loading()

    assert world.is_css_present('ul.new-component-type')
Exemplo n.º 39
0
def incorrect_lti_is_rendered(_step):
    # lti div has class rendered
    assert world.is_css_present('div.lti.rendered')

    # error is hidden
    assert not world.css_visible('.error_message')

    # iframe is visible
    assert world.css_visible('iframe')

    #inside iframe test content is presented
    with world.browser.get_iframe('ltiLaunchFrame') as iframe:
        # iframe does not contain functions from terrain/ui_helpers.py
        assert iframe.is_element_present_by_css('.result', wait_time=5)
        assert ("Wrong LTI signature" == world.retry_on_exception(
            lambda: iframe.find_by_css('.result')[0].text, max_attempts=5))
Exemplo n.º 40
0
def i_see_a_release_date_for_my_section(_step):
    import re

    css = 'span.published-status'
    assert world.is_css_present(css)
    status_text = world.css_text(css)

    # e.g. 11/06/2012 at 16:25
    msg = 'Release date:'
    date_regex = r'(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d\d?, \d{4}'
    if not re.search(date_regex, status_text):
        print status_text, date_regex
    time_regex = r'[0-2]\d:[0-5]\d( \w{3})?'
    if not re.search(time_regex, status_text):
        print status_text, time_regex
    match_string = r'%s\s+%s at %s' % (msg, date_regex, time_regex)
    if not re.match(match_string, status_text):
        print status_text, match_string
    assert re.match(match_string, status_text)
Exemplo n.º 41
0
def inputfield(problem_type, choice=None, input_num=1):
    """ Return the <input> element for *problem_type*.
    For example, if problem_type is 'string', return
    the text field for the string problem in the test course.

    *choice* is the name of the checkbox input in a group
    of checkboxes. """

    sel = ("input#input_i4x-edx-model_course-problem-%s_2_%s" %
           (problem_type.replace(" ", "_"), str(input_num)))

    if choice is not None:
        base = "_choice_" if problem_type == "multiple choice" else "_"
        sel = sel + base + str(choice)

    # If the input element doesn't exist, fail immediately
    assert world.is_css_present(sel)

    # Retrieve the input element
    return world.browser.find_by_css(sel)
Exemplo n.º 42
0
def create_a_course():
    world.scenario_dict['COURSE'] = world.CourseFactory.create(org='MITx', course='999', display_name='Robot Super Course')

    # Add the user to the instructor group of the course
    # so they will have the permissions to see it in studio

    course = world.GroupFactory.create(name='instructor_MITx/{}/{}'.format(world.scenario_dict['COURSE'].number,
                                                                    world.scenario_dict['COURSE'].display_name.replace(" ", "_")))
    if world.scenario_dict.get('USER') is None:
        user = world.scenario_dict['USER']
    else:
        user = get_user_by_email('*****@*****.**')
    user.groups.add(course)
    user.save()
    world.browser.reload()

    course_link_css = 'span.class-name'
    world.css_click(course_link_css)
    course_title_css = 'span.course-title'
    assert_true(world.is_css_present(course_title_css))
Exemplo n.º 43
0
def create_a_course():
    world.CourseFactory.create(org=_COURSE_ORG,
                               course=_COURSE_NUM,
                               display_name=_COURSE_NAME)

    # Add the user to the instructor group of the course
    # so they will have the permissions to see it in studio
    course = world.GroupFactory.create(
        name='instructor_MITx/{course_num}/{course_name}'.format(
            course_num=_COURSE_NUM, course_name=_COURSE_NAME.replace(" ",
                                                                     "_")))
    user = get_user_by_email('*****@*****.**')
    user.groups.add(course)
    user.save()
    world.browser.reload()

    course_link_css = 'span.class-name'
    world.css_click(course_link_css)
    course_title_css = 'span.course-title'
    assert_true(world.is_css_present(course_title_css))
Exemplo n.º 44
0
def create_a_course():
    course = world.CourseFactory.create(org='MITx', course='999', display_name='Robot Super Course')
    world.scenario_dict['COURSE'] = course

    user = world.scenario_dict.get("USER")
    if not user:
        user = get_user_by_email('*****@*****.**')

    # Add the user to the instructor group of the course
    # so they will have the permissions to see it in studio
    for role in ("staff", "instructor"):
        groupname = get_course_groupname_for_role(course.location, role)
        group, __ = Group.objects.get_or_create(name=groupname)
        user.groups.add(group)
    user.save()

    # Navigate to the studio dashboard
    world.visit('/')
    course_link_css = 'a.course-link'
    world.css_click(course_link_css)
    course_title_css = 'span.course-title'
    assert_true(world.is_css_present(course_title_css))
Exemplo n.º 45
0
def lti_is_rendered(_step, rendered_in):
    if rendered_in.strip() == 'iframe':
        assert world.is_css_present('iframe', wait_time=2)
        assert not world.is_css_present('.link_lti_new_window', wait_time=0)
        assert not world.is_css_present('.error_message', wait_time=0)

        # iframe is visible
        assert world.css_visible('iframe')
        check_lti_iframe_content("This is LTI tool. Success.")

    elif rendered_in.strip() == 'new page':
        assert not world.is_css_present('iframe', wait_time=2)
        assert world.is_css_present('.link_lti_new_window', wait_time=0)
        assert not world.is_css_present('.error_message', wait_time=0)
        check_lti_popup()
    else:  # incorrent rendered_in parameter
        assert False
Exemplo n.º 46
0
def create_course_with_unit():
    """
    Prepare for tests by creating a course with a section, subsection, and unit.
    Performs the following:
        Clear out all courseware
        Create a course with a section, subsection, and unit
        Create a user and make that user a course author
        Log the user into studio
        Open the course from the dashboard
        Expand the section and click on the New Unit link
    The end result is the page where the user is editing the new unit
    """
    world.clear_courses()
    course = world.CourseFactory.create()
    world.scenario_dict['COURSE'] = course
    section = world.ItemFactory.create(parent_location=course.location)
    world.ItemFactory.create(
        parent_location=section.location,
        category='sequential',
        display_name='Subsection One',
    )
    user = create_studio_user(is_staff=False)
    add_course_author(user, course)

    log_into_studio()
    world.css_click('a.course-link')

    world.wait_for_js_to_load()
    css_selectors = [
        'div.section-item a.expand-collapse-icon', 'a.new-unit-item'
    ]
    for selector in css_selectors:
        world.css_click(selector)

    world.wait_for_mathjax()
    world.wait_for_xmodule()

    assert world.is_css_present('ul.new-component-type')
Exemplo n.º 47
0
def assert_answer_mark(step, problem_type, correctness):
    """
    Assert that the expected answer mark is visible
    for a given problem type.

    *problem_type* is a string identifying the type of problem (e.g. 'drop down')
    *correctness* is in ['correct', 'incorrect', 'unanswered']
    """

    # Determine which selector(s) to look for based on correctness
    assert (correctness in ['correct', 'incorrect', 'unanswered'])
    assert (problem_type in PROBLEM_DICT)

    # At least one of the correct selectors should be present
    for sel in PROBLEM_DICT[problem_type][correctness]:
        has_expected = world.is_css_present(sel)

        # As soon as we find the selector, break out of the loop
        if has_expected:
            break

    # Expect that we found the expected selector
    assert (has_expected)
Exemplo n.º 48
0
def video_takes_a_single_click(_step):
    component_css = '.xmodule_VideoModule'
    assert world.is_css_not_present(component_css)

    world.css_click("a[data-category='video']")
    assert world.is_css_present(component_css)
Exemplo n.º 49
0
def see_full_output_link(step):
    assert world.is_css_present('a.full')
Exemplo n.º 50
0
def see_the_red_x(step):
    assert world.is_css_present('div.grader-status > span.incorrect')
Exemplo n.º 51
0
def i_see_complete_subsection_name_with_quote_in_editor(step):
    css = '.subsection-display-name-input'
    assert world.is_css_present(css)
    assert_equal(world.css_value(css), 'Subsection With "Quote"')
Exemplo n.º 52
0
def i_visit_the_homepage(step):
    world.visit('/')
    assert world.is_css_present('header.global')
Exemplo n.º 53
0
def action_button_present(_step, buttonname, doesnt_appear):
    button_css = 'section.action input[value*="%s"]' % buttonname
    if doesnt_appear:
        assert world.is_css_not_present(button_css)
    else:
        assert world.is_css_present(button_css)
Exemplo n.º 54
0
def i_register_for_the_course(_step, course):
    url = django_url('courses/%s/about' %
                     world.scenario_dict['COURSE'].id.to_deprecated_string())
    world.browser.visit(url)
    world.css_click('.intro a.register')
    assert world.is_css_present('.container.dashboard')
Exemplo n.º 55
0
def i_should_see_that_course_in_my_dashboard(_step, doesnt_appear, course):
    course_link_css = '.my-courses a[href*="%s"]' % course
    if doesnt_appear:
        assert world.is_css_not_present(course_link_css)
    else:
        assert world.is_css_present(course_link_css)
Exemplo n.º 56
0
def i_should_see_empty_dashboard(_step):
    empty_dash_css = '.empty-dashboard-message'
    assert world.is_css_present(empty_dash_css)
Exemplo n.º 57
0
def i_visit_the_dashboard(step):
    world.visit('/dashboard')
    assert world.is_css_present('section.container.dashboard')
Exemplo n.º 58
0
def i_should_be_on_the_dashboard(step):
    assert world.is_css_present('section.container.dashboard')
    assert world.browser.title == 'Dashboard'
Exemplo n.º 59
0
def i_am_on_the_courses_page(step):
    world.visit('/courses')
    assert world.is_css_present('section.courses')
def i_am_on_the_dashboard_page(step):
    assert world.is_css_present('section.courses')
    assert world.url_equals('/dashboard')