From 4f795f8270c2cd9ef0b4075e6597eee01a1e21bf Mon Sep 17 00:00:00 2001 From: Don Mitchell Date: Wed, 1 Oct 2014 15:40:27 -0400 Subject: [PATCH] Fix hardcoded course urls --- cms/djangoapps/contentstore/features/grading.py | 10 ++-------- common/djangoapps/terrain/steps.py | 4 ++++ lms/djangoapps/courseware/features/events.feature | 10 +++++----- lms/djangoapps/courseware/features/events.py | 5 +++++ lms/djangoapps/courseware/features/login.feature | 4 ++-- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/cms/djangoapps/contentstore/features/grading.py b/cms/djangoapps/contentstore/features/grading.py index 431b6d06b5..3c2d9c4495 100644 --- a/cms/djangoapps/contentstore/features/grading.py +++ b/cms/djangoapps/contentstore/features/grading.py @@ -61,20 +61,14 @@ def change_assignment_name(step, old_name, new_name): index = get_type_index(old_name) f = world.css_find(name_id)[index] assert_not_equal(index, -1) - for count in range(len(old_name)): + for __ in xrange(len(old_name)): f._element.send_keys(Keys.END, Keys.BACK_SPACE) f._element.send_keys(new_name) @step(u'I go back to the main course page') def main_course_page(step): - course_name = world.scenario_dict['COURSE'].display_name.replace(' ', '_') - course_key = SlashSeparatedCourseKey( - world.scenario_dict['COURSE'].org, - world.scenario_dict['COURSE'].number, - course_name - ) - main_page_link = reverse_course_url('course_handler', course_key) + main_page_link = reverse_course_url('course_handler', world.scenario_dict['COURSE'].id) world.visit(main_page_link) assert_in('Course Outline', world.css_text('h1.page-header')) diff --git a/common/djangoapps/terrain/steps.py b/common/djangoapps/terrain/steps.py index 5e20b0a1d0..5f51315de8 100644 --- a/common/djangoapps/terrain/steps.py +++ b/common/djangoapps/terrain/steps.py @@ -81,6 +81,8 @@ def click_the_link_with_the_text_group1(step, linktext): @step('I should see that the path is "([^"]*)"$') def i_should_see_that_the_path_is(step, path): + if 'COURSE' in world.scenario_dict: + path = path.format(world.scenario_dict['COURSE'].id) assert world.url_equals(path), ( "path should be {!r} but is {!r}".format(path, world.browser.url) ) @@ -185,6 +187,8 @@ def dialogs_are_closed(step): @step(u'visit the url "([^"]*)"') def visit_url(step, url): + if 'COURSE' in world.scenario_dict: + url = url.format(world.scenario_dict['COURSE'].id) world.browser.visit(lettuce.django.django_url(url)) diff --git a/lms/djangoapps/courseware/features/events.feature b/lms/djangoapps/courseware/features/events.feature index 3ffe817ca6..6cb02363f4 100644 --- a/lms/djangoapps/courseware/features/events.feature +++ b/lms/djangoapps/courseware/features/events.feature @@ -5,10 +5,10 @@ Feature: LMS.Events Scenario Outline: An event is emitted for each request Given: I am registered for the course "6.002x" And I visit the url "" - Then a "" server event is emitted + Then a course url "" event is emitted Examples: - | url | - | /dashboard | - | /courses/edx/6.002x/Test_Course/info | - | /courses/edx/6.002x/Test_Course/courseware | + | url | + | /dashboard | + | /courses/{}/info | + | /courses/{}/courseware | diff --git a/lms/djangoapps/courseware/features/events.py b/lms/djangoapps/courseware/features/events.py index dc20f7fbe4..cc81c129f7 100644 --- a/lms/djangoapps/courseware/features/events.py +++ b/lms/djangoapps/courseware/features/events.py @@ -36,6 +36,11 @@ def reset_between_outline_scenarios(_scenario, order, outline, reasons_to_fail): world.event_collection.drop() +@step(r'[aA]n? course url "(.*)" event is emitted$') +def course_url_event_is_emitted(_step, url_regex): + event_type = url_regex.format(world.scenario_dict['COURSE'].id) + n_events_are_emitted(_step, 1, event_type, "server") + @step(r'([aA]n?|\d+) "(.*)" (server|browser) events? is emitted$') def n_events_are_emitted(_step, count, event_type, event_source): diff --git a/lms/djangoapps/courseware/features/login.feature b/lms/djangoapps/courseware/features/login.feature index 3c4d006fb9..3576a1adaf 100644 --- a/lms/djangoapps/courseware/features/login.feature +++ b/lms/djangoapps/courseware/features/login.feature @@ -34,8 +34,8 @@ Feature: LMS.Login in as a registered user And The course "6.002x" exists And I am registered for the course "6.002x" And I am not logged in - And I visit the url "/courses/edx/6.002x/Test_Course/courseware" - And I should see that the path is "/accounts/login?next=/courses/edx/6.002x/Test_Course/courseware" + And I visit the url "/courses/{}/courseware" + And I should see that the path is "/accounts/login?next=/courses/{}/courseware" When I submit my credentials on the login form And I wait for "2" seconds Then the page title should contain "6.002x Courseware"