Commit 4f795f82 by Don Mitchell

Fix hardcoded course urls

parent 2a8529d3
...@@ -61,20 +61,14 @@ def change_assignment_name(step, old_name, new_name): ...@@ -61,20 +61,14 @@ def change_assignment_name(step, old_name, new_name):
index = get_type_index(old_name) index = get_type_index(old_name)
f = world.css_find(name_id)[index] f = world.css_find(name_id)[index]
assert_not_equal(index, -1) 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(Keys.END, Keys.BACK_SPACE)
f._element.send_keys(new_name) f._element.send_keys(new_name)
@step(u'I go back to the main course page') @step(u'I go back to the main course page')
def main_course_page(step): def main_course_page(step):
course_name = world.scenario_dict['COURSE'].display_name.replace(' ', '_') main_page_link = reverse_course_url('course_handler', world.scenario_dict['COURSE'].id)
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)
world.visit(main_page_link) world.visit(main_page_link)
assert_in('Course Outline', world.css_text('h1.page-header')) assert_in('Course Outline', world.css_text('h1.page-header'))
......
...@@ -81,6 +81,8 @@ def click_the_link_with_the_text_group1(step, linktext): ...@@ -81,6 +81,8 @@ def click_the_link_with_the_text_group1(step, linktext):
@step('I should see that the path is "([^"]*)"$') @step('I should see that the path is "([^"]*)"$')
def i_should_see_that_the_path_is(step, path): 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), ( assert world.url_equals(path), (
"path should be {!r} but is {!r}".format(path, world.browser.url) "path should be {!r} but is {!r}".format(path, world.browser.url)
) )
...@@ -185,6 +187,8 @@ def dialogs_are_closed(step): ...@@ -185,6 +187,8 @@ def dialogs_are_closed(step):
@step(u'visit the url "([^"]*)"') @step(u'visit the url "([^"]*)"')
def visit_url(step, 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)) world.browser.visit(lettuce.django.django_url(url))
......
...@@ -5,10 +5,10 @@ Feature: LMS.Events ...@@ -5,10 +5,10 @@ Feature: LMS.Events
Scenario Outline: An event is emitted for each request Scenario Outline: An event is emitted for each request
Given: I am registered for the course "6.002x" Given: I am registered for the course "6.002x"
And I visit the url "<url>" And I visit the url "<url>"
Then a "<url>" server event is emitted Then a course url "<url>" event is emitted
Examples: Examples:
| url | | url |
| /dashboard | | /dashboard |
| /courses/edx/6.002x/Test_Course/info | | /courses/{}/info |
| /courses/edx/6.002x/Test_Course/courseware | | /courses/{}/courseware |
...@@ -36,6 +36,11 @@ def reset_between_outline_scenarios(_scenario, order, outline, reasons_to_fail): ...@@ -36,6 +36,11 @@ def reset_between_outline_scenarios(_scenario, order, outline, reasons_to_fail):
world.event_collection.drop() 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$') @step(r'([aA]n?|\d+) "(.*)" (server|browser) events? is emitted$')
def n_events_are_emitted(_step, count, event_type, event_source): def n_events_are_emitted(_step, count, event_type, event_source):
......
...@@ -34,8 +34,8 @@ Feature: LMS.Login in as a registered user ...@@ -34,8 +34,8 @@ Feature: LMS.Login in as a registered user
And The course "6.002x" exists And The course "6.002x" exists
And I am registered for the course "6.002x" And I am registered for the course "6.002x"
And I am not logged in And I am not logged in
And I visit the url "/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/edx/6.002x/Test_Course/courseware" And I should see that the path is "/accounts/login?next=/courses/{}/courseware"
When I submit my credentials on the login form When I submit my credentials on the login form
And I wait for "2" seconds And I wait for "2" seconds
Then the page title should contain "6.002x Courseware" Then the page title should contain "6.002x Courseware"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment