From fba50589ff0093d45d7e3868be4fbec3d9f3168f Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Tue, 30 Jul 2013 13:47:29 -0400 Subject: [PATCH] Add a lettuce test for course team admins granting admin status --- .../contentstore/features/common.py | 8 ++++ .../contentstore/features/course-team.feature | 13 ++++++ .../contentstore/features/course-team.py | 43 ++++++++++++++----- cms/templates/manage_users.html | 14 +++--- 4 files changed, 62 insertions(+), 16 deletions(-) diff --git a/cms/djangoapps/contentstore/features/common.py b/cms/djangoapps/contentstore/features/common.py index d357c8ae96..bf8c2ee264 100644 --- a/cms/djangoapps/contentstore/features/common.py +++ b/cms/djangoapps/contentstore/features/common.py @@ -53,6 +53,14 @@ def i_have_opened_a_new_course(_step): open_new_course() +@step('(I select|s?he selects) the new course') +def select_new_course(_step, whom): + course_link_xpath = '//div[contains(@class, "courses")]//a[contains(@class, "class-link")]//span[contains(., "{name}")]/..'.format( + name="Robot Super Course") + element = world.browser.find_by_xpath(course_link_xpath) + element.click() + + @step(u'I press the "([^"]*)" notification button$') def press_the_notification_button(_step, name): css = 'a.action-%s' % name.lower() diff --git a/cms/djangoapps/contentstore/features/course-team.feature b/cms/djangoapps/contentstore/features/course-team.feature index fc1212f398..77870112e7 100644 --- a/cms/djangoapps/contentstore/features/course-team.feature +++ b/cms/djangoapps/contentstore/features/course-team.feature @@ -32,3 +32,16 @@ Feature: Course Team And I am viewing the course team settings When I add "dennis" to the course team Then I should see "Could not find user by email address" somewhere on the page + + Scenario: Admins should be able to make other people into admins + Given I have opened a new course in Studio + And the user "emily" exists + And I am viewing the course team settings + And I add "emily" to the course team + When I make "emily" a course team admin + And "emily" logs in + And she selects the new course + And she views the course team settings + Then "emily" should be marked as an admin + And she can add users + And she can delete users diff --git a/cms/djangoapps/contentstore/features/course-team.py b/cms/djangoapps/contentstore/features/course-team.py index cad07a990e..96bd9dd388 100644 --- a/cms/djangoapps/contentstore/features/course-team.py +++ b/cms/djangoapps/contentstore/features/course-team.py @@ -8,8 +8,8 @@ PASSWORD = 'test' EMAIL_EXTENSION = '@edx.org' -@step(u'I am viewing the course team settings') -def view_grading_settings(_step): +@step(u'(I am viewing|s?he views) the course team settings') +def view_grading_settings(_step, whom): world.click_course_settings() link_css = 'li.nav-course-settings-team a' world.css_click(link_css) @@ -41,29 +41,52 @@ def delete_other_user(_step, name): world.css_click(to_delete_css) +@step(u'I make "([^"]*)" a course team admin') +def make_course_team_admin(_step, name): + admin_btn_css = '.user-item[data-email="{email}"] .user-actions .add-admin-role'.format( + email=name+EMAIL_EXTENSION) + world.css_click(admin_btn_css) + + @step(u'"([^"]*)" logs in$') def other_user_login(_step, name): log_into_studio(uname=name, password=PASSWORD, email=name + EMAIL_EXTENSION) @step(u's?he does( not)? see the course on (his|her) page') -def see_course(_step, doesnt_see_course, gender): +def see_course(_step, inverted, gender): class_css = 'span.class-name' all_courses = world.css_find(class_css, wait_time=1) all_names = [item.html for item in all_courses] - if doesnt_see_course: + if inverted: assert not world.scenario_dict['COURSE'].display_name in all_names else: assert world.scenario_dict['COURSE'].display_name in all_names -@step(u's?he cannot delete users') -def cannot_delete(_step): +@step(u'"([^"]*)" should( not)? be marked as an admin') +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) + + +@step(u's?he can(not)? delete users') +def can_delete_users(_step, inverted): to_delete_css = 'a.remove-user' - assert world.is_css_not_present(to_delete_css) + if inverted: + assert world.is_css_not_present(to_delete_css) + else: + assert world.is_css_present(to_delete_css) -@step(u's?he cannot add users') -def cannot_add(_step): +@step(u's?he can(not)? add users') +def can_add_users(_step, inverted): add_css = 'a.create-user-button' - assert world.is_css_not_present(add_css) + if inverted: + assert world.is_css_not_present(add_css) + else: + assert world.is_css_present(add_css) diff --git a/cms/templates/manage_users.html b/cms/templates/manage_users.html index 42b4fe6a95..d522b5e8b9 100644 --- a/cms/templates/manage_users.html +++ b/cms/templates/manage_users.html @@ -57,12 +57,14 @@
    % for user in staff: -
  1. + <% api_url = reverse('course_team_user', kwargs=dict( + org=context_course.location.org, + course=context_course.location.course, + name=context_course.location.name, + email=user.email, + )) + %> +
  2. <% is_instuctor = is_user_in_course_group_role(user, context_course.location, 'instructor', check_staff=False) %> % if is_instuctor: