def i_created_raw_html(step): step.given('I am in Studio editing a new unit') world.create_component_instance( step=step, category='html', component_type='Raw HTML' )
def xml_only_video(step): # Create a new video *without* metadata. This requires a certain # amount of rummaging to make sure all the correct data is present step.given('I have clicked the new unit button') # Wait for the new unit to be created and to load the page world.wait(1) location = world.scenario_dict['COURSE'].location store = get_modulestore(location) parent_location = store.get_items(Location(category='vertical', revision='draft'))[0].location youtube_id = 'ABCDEFG' world.scenario_dict['YOUTUBE_ID'] = youtube_id # Create a new Video component, but ensure that it doesn't have # metadata. This allows us to test that we are correctly parsing # out XML video = world.ItemFactory.create( parent_location=parent_location, category='video', data='<video youtube="1.00:%s"></video>' % youtube_id ) # Refresh to see the new video reload_the_page(step)
def see_section_content(step, section): world.wait(0.5) if section == "2": text = 'The correct answer is Option 2' elif section == "1": text = 'The correct answer is Choice 3' step.given('I should see "' + text + '" somewhere on the page')
def given_the_switchboard_is_configured_for_ldap_lookup_with_location(step): context_helper.add_or_replace_context('__switchboard_directory', 'Switchboard', 'internal') step.given('Given the LDAP server is configured and active') ldap_action_webi.add_or_replace_ldap_server('openldap-dev', 'openldap-dev.lan-quebec.avencall.com') ldap_action_webi.add_or_replace_ldap_filter( name='openldap-dev', server='openldap-dev', base_dn='dc=lan-quebec,dc=avencall,dc=com', username='******', password='******', display_name=['cn', 'st']) directory_action_webi.add_or_replace_directory( 'openldap', 'ldapfilter://openldap-dev', 'cn,telephoneNumber,st', '', {'name': 'cn', 'number': 'telephoneNumber', 'location': 'st'} ) directory_action_webi.add_or_replace_display( 'switchboard', [('Icon', 'status', ''), ('Name', 'name', '{db-name}'), ('Number', 'number_office', '{db-number}'), ('Location', '', '{db-location}')] ) directory_action_webi.assign_filter_and_directories_to_context( '__switchboard_directory', 'switchboard', ['openldap'] )
def test_open_url_without_tree(step): step.given('I go to the "/" view without tree') # make sure that text in place assert_true('Test Header' in world.response_body) assert_equal(world.tree, None)
def adminlogin(step,usrID): step.given('I fill in the input with name "#login-email" with "*****@*****.**"') step.given('I fill in the input with name "#login-password" with "jason-uguru-2"') step.given('I click the element with css selector "#sign-in-button"') step.given('I visit "https://uguru.me/admin/users/5919/"') step.given('I click the element with css selector "[href="/admin/users/'+usrID+'/login"]"') time.sleep(8)
def xml_only_video(step): # Create a new video *without* metadata. This requires a certain # amount of rummaging to make sure all the correct data is present step.given("I have clicked the new unit button") # Wait for the new unit to be created and to load the page world.wait(1) course = world.scenario_dict["COURSE"] store = get_modulestore(course.location) parent_location = store.get_items(course.id, category="vertical", revision="draft")[0].location youtube_id = "ABCDEFG" world.scenario_dict["YOUTUBE_ID"] = youtube_id # Create a new Video component, but ensure that it doesn't have # metadata. This allows us to test that we are correctly parsing # out XML world.ItemFactory.create( parent_location=parent_location, category="video", data='<video youtube="1.00:%s"></video>' % youtube_id, modulestore=store, )
def xml_only_video(step): # Create a new video *without* metadata. This requires a certain # amount of rummaging to make sure all the correct data is present step.given('I have clicked the new unit button') # Wait for the new unit to be created and to load the page world.wait(1) course = world.scenario_dict['COURSE'] store = modulestore() parent_location = store.get_items(course.id, qualifiers={'category': 'vertical'})[0].location youtube_id = 'ABCDEFG' world.scenario_dict['YOUTUBE_ID'] = youtube_id # Create a new Video component, but ensure that it doesn't have # metadata. This allows us to test that we are correctly parsing # out XML world.ItemFactory.create( parent_location=parent_location, category='video', data='<video youtube="1.00:%s"></video>' % youtube_id, modulestore=store, user_id=world.scenario_dict["USER"].id )
def i_created_blank_html_page(step): step.given('I am in Studio editing a new unit') world.create_component_instance( step=step, category='html', component_type='Text' )
def i_created_etext_in_latex(step): step.given('I am in Studio editing a new unit') step.given('I have enabled latex compiler') world.create_component_instance( step=step, category='html', component_type='E-text Written in LaTeX' )
def i_created_unit_with_advanced_module(step, advanced_module): world.create_course_with_unit() url = world.browser.url step.given("I select the Advanced Settings") change_value(step, ADVANCED_MODULES_KEY, '["{}"]'.format(advanced_module)) world.visit(url) world.wait_for_xmodule()
def when_i_update_the_question_with_invalid_details(step): world.theme = Theme.objects.create(name='Sample Theme') question_data = {'text': '', 'instructions': '', 'export_label': '', 'theme': ''} world.page.fill_form(question_data) step.given('And I click save question button')
def i_created_unit_with_advanced_module(step, advanced_module): step.given('I am in Studio editing a new unit') url = world.browser.url step.given("I select the Advanced Settings") change_value(step, ADVANCED_MODULES_KEY, '["{}"]'.format(advanced_module)) world.visit(url) world.wait_for_xmodule()
def open_course_with_locked(step, lock_state, file_name): step.given('I have opened a new course in studio') step.given('I go to the files and uploads page') _write_test_file(file_name, "test file") step.given('I upload the file "' + file_name + '"') if lock_state == "locked": step.given('I lock "' + file_name + '"') step.given('I reload the page')
def i_created_etext_in_latex(step): world.create_course_with_unit() step.given('I have enabled latex compiler') world.create_component_instance( step=step, category='html', component_type='E-text Written in LaTeX' )
def wait_until_source_status_code_is(step, code1, code2, secs): start = datetime.utcnow() step.given('I get the source "{id}"'.format(id=world.source['resource'])) while (world.source['status']['code'] != int(code1) and world.source['status']['code'] != int(code2)): time.sleep(3) assert datetime.utcnow() - start < timedelta(seconds=int(secs)) step.given('I get the source "{id}"'.format(id=world.source['resource'])) assert world.source['status']['code'] == int(code1)
def visit_model_add_admin(step, model_name): step.given("Given the user navigates to the \"%s\" admin" % model_name) try: # This works in Django 1.3 world.browser.click_link_by_href("add/") except ElementDoesNotExist: # This works in Django 1.4 el = world.browser.find_by_css('.addlink').first el.click()
def create_latex_problem(step): step.given('I am in Studio editing a new unit') step.given('I have enabled latex compiler') world.create_component_instance( step=step, category='problem', component_type='Problem Written in LaTeX', is_advanced=True )
def create_latex_problem(step): world.create_course_with_unit() step.given('I have enabled latex compiler') world.create_component_instance( step=step, category='problem', component_type='Problem Written in LaTeX', is_advanced=True )
def wait_until_prediction_status_code_is(step, code1, code2, secs): start = datetime.utcnow() step.given('I get the prediction "{id}"'.format(id=world.prediction["resource"])) status = get_status(world.prediction) while status["code"] != int(code1) and status["code"] != int(code2): time.sleep(3) assert datetime.utcnow() - start < timedelta(seconds=int(secs)) step.given('I get the prediction "{id}"'.format(id=world.prediction["resource"])) status = get_status(world.prediction) assert status["code"] == int(code1)
def test_fill_particular_form(step): step.given('I go to the "/" view') name, val = "name", "name val" step.given('Fill the field "%s" with "%s" in form #2' % (name, val)) # should be filled first form because # 'name' and 'email' fields should be in first form form = world.tree.forms[1] assert_equal(form.inputs[name].value, val)
def click_asset_from_index(step, file_name): # This is not ideal, but I'm having trouble with the middleware not having # the same user in the request when I hit the URL directly. course_link_css = 'a.course-link' world.css_click(course_link_css) step.given("I go to the files and uploads page") index = get_index(file_name) assert index != -1 world.css_click('a.filename', index=index) _verify_body_text()
def i_can_open_a_packfile_named_group1(step, group1): store = world.focus_obj step.given("Then I look at the menubar") step.given("I should find a \"File\" menu") step.given("When I look at the menu I should find a \"Open PackFile\" entry") step.given("And click on it") step.given("Then I should get a file select dbox.") world.dialog.child(roleName='text').text = group1 world.dialog.button('Open').click() world.focus_obj = store
def i_am_logged_in(step): step.given('I am in the login page') step.behave_as(''' And I fill the form with the next info: | name | value | | username | admin | | password | admin | ''') step.then('submit the form') step.then('see the logged in home page')
def video_upload_is_enabled(step): if world.using_selenium: world.browser.get(django_url("/dashboard/sources/")) try: elt = world.browser.find_element_by_id("mediathread-video-upload") if elt: elt.click() step.given("I confirm the action") except NoSuchElementException: pass # It's already enabled. That's ok.
def test_form_not_contain_fields(step): step.given('I go to the "/" view') assert_equal(world.response_body.count( '<input type="checkbox" name="theme_selections_'), 3) step.given(""" There's form with following fields: | theme_selections_* | """)
def wait_until_batch_centroid_status_code_is(step, code1, code2, secs): start = datetime.utcnow() step.given('I get the batch centroid "{id}"'.format(id=world.batch_centroid['resource'])) status = get_status(world.batch_centroid) while (status['code'] != int(code1) and status['code'] != int(code2)): time.sleep(3) assert datetime.utcnow() - start < timedelta(seconds=int(secs)) step.given('I get the batch centroid "{id}"'.format(id=world.batch_centroid['resource'])) status = get_status(world.batch_centroid) assert status['code'] == int(code1)
def wait_until_evaluation_status_code_is(step, code1, code2, secs): start = datetime.utcnow() step.given('I get the evaluation "{id}"'.format(id=world.evaluation['resource'])) status = get_status(world.evaluation) while (status['code'] != int(code1) and status['code'] != int(code2)): time.sleep(3) assert datetime.utcnow() - start < timedelta(seconds=int(secs)) step.given('I get the evaluation "{id}"'.format(id=world.evaluation['resource'])) status = get_status(world.evaluation) assert status['code'] == int(code1)
def wait_until_anomaly_status_code_is(step, code1, code2, secs): start = datetime.utcnow() step.given('I get the anomaly detector "{id}"'.format(id=world.anomaly['resource'])) status = get_status(world.anomaly) while (status['code'] != int(code1) and status['code'] != int(code2)): time.sleep(3) assert datetime.utcnow() - start < timedelta(seconds=int(secs)) step.given('I get the anomaly detector "{id}"'.format(id=world.anomaly['resource'])) status = get_status(world.anomaly) assert status['code'] == int(code1)
def i_created_a_video_component(step): step.given('I have created a Video component') # Store the current URL so we can return here video_url = world.browser.url # Upload subtitles for the video using the upload interface step.given('I have uploaded subtitles') # Return to the video world.visit(video_url)
def return_to_course(step): step.given('I visit the homepage') world.click_link("View Course") world.click_link("Courseware")
def go_into_course(step): step.given('I am registered for the course "6.002x"') step.given('And I am logged in') step.given('And I click on View Courseware')
def nav_to_the_courseware_page_of_a_course_with_multiple_sections(step): step.given('I have a course with multiple sections') step.given('I navigate to the course overview page')
def cancel_does_not_save_changes(step): world.cancel_component(step) step.given("I edit and select Settings") step.given("I see the advanced settings and their expected values")
def i_am_on_advanced_course_settings(step): step.given('I have opened a new course in Studio') step.given('I select the Advanced Settings')
def open_pages_page_in_new_course(step): step.given('I have opened a new course in Studio') step.given('I go to the pages page')
def edit_new_unit(step): step.given('I have populated a new course in Studio') create_unit_from_course_outline()
def see_sequence_content(step, sequence): step.given('I should see the content of section "2"')
def see_section_content(step, section): if section == "2": text = 'The correct answer is Option 2' elif section == "1": text = 'The correct answer is Choice 3' step.given('I should see "' + text + '" somewhere on the page')
def i_created_blank_html_page(step): step.given('I am in Studio editing a new unit') world.create_component_instance(step=step, category='html', component_type='Text')
def i_created_etext_in_latex(step): step.given('I am in Studio editing a new unit') step.given('I have enabled latex compiler') world.create_component_instance(step=step, category='html', component_type='E-text Written in LaTeX')
def i_created_raw_html(step): step.given('I am in Studio editing a new unit') world.create_component_instance(step=step, category='html', component_type='Raw HTML')
def i_enabled_the_advanced_module(step, module): step.given('I have opened a new course section in Studio') world.css_click('.nav-course-settings') world.css_click('.nav-course-settings-advanced a') type_in_codemirror(0, '["%s"]' % module) press_the_notification_button(step, 'Save')
def see_recent_section(step, section): step.given('I should see "You were most recently in %s" somewhere on the page' % subsection_name(int(section)))
def i_created_etext_in_latex(step): world.create_course_with_unit() step.given('I have enabled latex compiler') world.create_component_instance(step=step, category='html', component_type='E-text Written in LaTeX')
def i_should_see_be_on_the_studio_home_page(step): step.given('I should see the message "My Courses"')
def prepare(step): step.given("I have 'msg_sender' test config") step.given("I stop 'mysql' service") step.given("I start 'mysql' service") step.given("I drop test database") step.given("I create test database") step.given("I create table 'messages'") step.given("I create table 'farms'") step.given("I create table 'farm_role_settings'") step.given("I create table 'servers'") step.given("I create table 'farm_roles'") step.given("I create table 'server_properties'") step.given("I create table 'farm_settings'") step.given("I create table 'role_behaviors'") step.given("I create table 'events'")
def open_new_unit(step): step.given('I have opened a new course section in Studio') step.given('I have added a new subsection') step.given('I expand the first section') world.css_click('a.new-unit-item')
def enable_latex_compiler(step): url = world.browser.url step.given("I select the Advanced Settings") change_value(step, 'Enable LaTeX Compiler', 'true') world.visit(url) world.wait_for_xmodule()
def i_have_opened_checklists(step): step.given('I have opened a new course in Studio') step.given('I select Checklists from the Tools menu')
def i_created_blank_common_problem(step): step.given('I am in Studio editing a new unit') step.given("I have created another Blank Common Problem")
def i_am_brought_back_to_course_outline(step): step.given('I see the four default edX checklists') # In a previous step, we selected (1, 0) in order to click the 'Edit Course Outline' link. # Make sure the task is still showing as selected (there was a caching bug with the collection). verifyChecklist2Status(1, 7, 14)
def i_export_the_course(step): step.given('I go to the export page') world.css_click('a.action-export')
def i_am_brought_to_help_page_in_new_window(step): step.given('I see the four default edX checklists') windows = world.browser.windows assert_equal(2, len(windows)) world.browser.switch_to_window(windows[1]) assert_equal('http://help.edge.edx.org/', world.browser.url)
def delete_all_components(step): count = len(world.css_find('ol.components li.component')) step.given('I delete "' + str(count) + '" component')
def populate_course(step): step.given('I have added a new section') step.given('I have added a new subsection')
def add_component_category(step, component, category): assert category in ('single step', 'HTML', 'Problem', 'Advanced Problem') given_string = 'I add this type of {} component:'.format(category) step.given('{}\n{}\n{}'.format(given_string, '|Component|', '|{}|'.format(component)))
def logged_into_twitter(step): step.given('I have no cookies') step.given('I go to "http://twitter.com/"') step.given('I should see "Sign in"') world.browser.find_element_by_partial_link_text('Sign in').click() step.given('I fill in "username" with "%s"' % world.twitter_username) step.given('I fill in "password" with "%s"' % world.twitter_password) step.given('I press "Sign in"') elems = wait_for_elem(world.browser, '//*[contains(., "Your Tweets")]', 4) if not elems: world.browser.refresh() elems = wait_for_elem(world.browser, '//*[contains(., "Your Tweets")]', 4)
def i_have_opened_a_new_subsection(step): step.given('I have opened a new course section in Studio') step.given('I have added a new subsection') world.css_click('span.subsection-name-value')
def create_static_page(step): step.given('I have opened the pages page in a new course') step.given('I add a new static page')