From eaac4f8bdc540f56b908a0263def8a4f5a115226 Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Tue, 30 Jul 2013 14:23:02 -0400 Subject: [PATCH] Add a lettuce test for course team admins removing admin status --- .../contentstore/features/common.py | 2 ++ .../contentstore/features/course-team.feature | 12 +++++++++++ .../contentstore/features/course-team.py | 21 ++++++++++++++++--- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/cms/djangoapps/contentstore/features/common.py b/cms/djangoapps/contentstore/features/common.py index bf8c2ee264..648ca680b9 100644 --- a/cms/djangoapps/contentstore/features/common.py +++ b/cms/djangoapps/contentstore/features/common.py @@ -126,6 +126,8 @@ def create_studio_user( registration.register(studio_user) registration.activate() + return studio_user + def fill_in_course_info( name='Robot Super Course', diff --git a/cms/djangoapps/contentstore/features/course-team.feature b/cms/djangoapps/contentstore/features/course-team.feature index 77870112e7..f7812de59e 100644 --- a/cms/djangoapps/contentstore/features/course-team.feature +++ b/cms/djangoapps/contentstore/features/course-team.feature @@ -45,3 +45,15 @@ Feature: Course Team Then "emily" should be marked as an admin And she can add users And she can delete users + + Scenario: Admins should be able to remove other admins + Given I have opened a new course in Studio + And the user "frank" exists as a course admin + And I am viewing the course team settings + When I remove admin rights from "frank" + And "frank" logs in + And he selects the new course + And he views the course team settings + Then "frank" should not be marked as an admin + And he cannot add users + And he cannot delete users diff --git a/cms/djangoapps/contentstore/features/course-team.py b/cms/djangoapps/contentstore/features/course-team.py index 96bd9dd388..18456b15f7 100644 --- a/cms/djangoapps/contentstore/features/course-team.py +++ b/cms/djangoapps/contentstore/features/course-team.py @@ -3,6 +3,8 @@ from lettuce import world, step from common import create_studio_user, log_into_studio +from django.contrib.auth.models import Group +from auth.authz import get_course_groupname_for_role PASSWORD = 'test' EMAIL_EXTENSION = '@edx.org' @@ -15,9 +17,15 @@ def view_grading_settings(_step, whom): world.css_click(link_css) -@step(u'the user "([^"]*)" exists$') -def create_other_user(_step, name): - create_studio_user(uname=name, password=PASSWORD, email=(name + EMAIL_EXTENSION)) +@step(u'the user "([^"]*)" exists( as a course admin)?$') +def create_other_user(_step, name, course_admin): + user = create_studio_user(uname=name, password=PASSWORD, email=(name + EMAIL_EXTENSION)) + if course_admin: + location = world.scenario_dict["COURSE"].location + for role in ("staff", "instructor"): + group, __ = Group.objects.get_or_create(name=get_course_groupname_for_role(location, role)) + user.groups.add(group) + user.save() @step(u'I add "([^"]*)" to the course team') @@ -48,6 +56,13 @@ def make_course_team_admin(_step, name): world.css_click(admin_btn_css) +@step(u'I remove admin rights from "([^"]*)"') +def remove_course_team_admin(_step, name): + admin_btn_css = '.user-item[data-email="{email}"] .user-actions .remove-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)