From d8a79016885966aea34727f0471b92d53743bf73 Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Thu, 1 Aug 2013 14:44:38 -0400 Subject: [PATCH] Add a lettuce test for removing own admin permission on course team --- .../contentstore/features/course-team.feature | 13 +++++++++++++ .../contentstore/features/course-team.py | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/cms/djangoapps/contentstore/features/course-team.feature b/cms/djangoapps/contentstore/features/course-team.feature index 2876d6236b..20171eeae5 100644 --- a/cms/djangoapps/contentstore/features/course-team.feature +++ b/cms/djangoapps/contentstore/features/course-team.feature @@ -71,3 +71,16 @@ Feature: Course Team And she deletes me from the course team And I log in Then I do not see the course on my page + + Scenario: Admins should be able to remove their own admin rights + Given I have opened a new course in Studio + And the user "harry" exists as a course admin + And I am viewing the course team settings + Then I should be marked as an admin + And I can add users + And I can delete users + When I remove admin rights from myself + Then I should not be marked as an admin + And I cannot add users + And I cannot delete users + And I cannot make myself a course team admin diff --git a/cms/djangoapps/contentstore/features/course-team.py b/cms/djangoapps/contentstore/features/course-team.py index 28f7307f70..57545060c1 100644 --- a/cms/djangoapps/contentstore/features/course-team.py +++ b/cms/djangoapps/contentstore/features/course-team.py @@ -112,6 +112,11 @@ def marked_as_admin(_step, name, inverted): assert world.is_css_present(flag_css) +@step(u'I should( not)? be marked as an admin') +def self_marked_as_admin(_step, inverted): + return marked_as_admin(_step, "robot+studio", inverted) + + @step(u'I can(not)? delete users') @step(u's?he can(not)? delete users') def can_delete_users(_step, inverted): @@ -130,3 +135,17 @@ def can_add_users(_step, inverted): assert world.is_css_not_present(add_css) else: assert world.is_css_present(add_css) + + +@step(u'I can(not)? make ("([^"]*)"|myself) a course team admin') +@step(u's?he can(not)? make ("([^"]*)"|me) a course team admin') +def can_make_course_admin(_step, inverted, outer_capture, name): + if outer_capture == "myself": + email = world.scenario_dict["USER"].email + else: + email = name + EMAIL_EXTENSION + add_button_css = '.user-item[data-email="{email}"] .add-admin-role'.format(email=email) + if inverted: + assert world.is_css_not_present(add_button_css) + else: + assert world.is_css_present(add_button_css)