course-team.py 4.18 KB
Newer Older
1
# pylint: disable=missing-docstring
2
# pylint: disable=redefined-outer-name
3 4

from lettuce import world, step
5
from nose.tools import assert_in  # pylint: disable=no-name-in-module
6 7


8
@step(u'(I am viewing|s?he views) the course team settings$')
9
def view_grading_settings(_step, whom):
10 11 12 13 14
    world.click_course_settings()
    link_css = 'li.nav-course-settings-team a'
    world.css_click(link_css)


15
@step(u'I add "([^"]*)" to the course team$')
16
def add_other_user(_step, name):
17
    new_user_css = 'a.create-user-button'
JonahStanley committed
18
    world.css_click(new_user_css)
19 20 21 22

    # Wait for the css animation to apply the is-shown class
    shown_css = 'div.wrapper-create-user.is-shown'
    world.wait_for_present(shown_css)
23

24
    email_css = 'input#user-email-input'
cahrens committed
25
    world.css_fill(email_css, name + '@edx.org')
26 27
    if world.is_firefox():
        world.trigger_event(email_css)
28
    confirm_css = 'form.create-user button.action-primary'
JonahStanley committed
29
    world.css_click(confirm_css)
30 31


32
@step(u'I delete "([^"]*)" from the course team$')
33
def delete_other_user(_step, name):
34
    to_delete_css = '.user-item .item-actions a.remove-user[data-id="{email}"]'.format(
cahrens committed
35
        email="{0}{1}".format(name, '@edx.org'))
JonahStanley committed
36
    world.css_click(to_delete_css)
37
    world.confirm_studio_prompt()
38 39


40
@step(u's?he deletes me from the course team$')
41 42 43 44
def other_delete_self(_step):
    to_delete_css = '.user-item .item-actions a.remove-user[data-id="{email}"]'.format(
        email="robot+studio@edx.org")
    world.css_click(to_delete_css)
45
    world.confirm_studio_prompt()
46 47


48
@step(u'I make "([^"]*)" a course team admin$')
49
def make_course_team_admin(_step, name):
Jay Zoldak committed
50 51
    admin_btn_css = '.user-item[data-email="{name}@edx.org"] .user-actions .add-admin-role'.format(
        name=name)
52 53 54
    world.css_click(admin_btn_css)


55
@step(u'I remove admin rights from ("([^"]*)"|myself)$')
56 57 58 59
def remove_course_team_admin(_step, outer_capture, name):
    if outer_capture == "myself":
        email = world.scenario_dict["USER"].email
    else:
cahrens committed
60
        email = name + '@edx.org'
61
    admin_btn_css = '.user-item[data-email="{email}"] .user-actions .remove-admin-role'.format(
62
        email=email)
63 64 65
    world.css_click(admin_btn_css)


66 67
@step(u'I( do not)? see the course on my page$')
@step(u's?he does( not)? see the course on (his|her) page$')
68
def see_course(_step, do_not_see, gender='self'):
69
    class_css = 'h3.course-title'
70
    if do_not_see:
71
        assert world.is_css_not_present(class_css)
72
    else:
73 74 75
        all_courses = world.css_find(class_css)
        all_names = [item.html for item in all_courses]
        assert_in(world.scenario_dict['COURSE'].display_name, all_names)
76 77


78
@step(u'"([^"]*)" should( not)? be marked as an admin$')
79
def marked_as_admin(_step, name, not_marked_admin):
Jay Zoldak committed
80 81
    flag_css = '.user-item[data-email="{name}@edx.org"] .flag-role.flag-role-admin'.format(
        name=name)
82
    if not_marked_admin:
83 84 85 86 87
        assert world.is_css_not_present(flag_css)
    else:
        assert world.is_css_present(flag_css)


88
@step(u'I should( not)? be marked as an admin$')
89 90
def self_marked_as_admin(_step, not_marked_admin):
    return marked_as_admin(_step, "robot+studio", not_marked_admin)
91 92


93 94
@step(u'I can(not)? delete users$')
@step(u's?he can(not)? delete users$')
95
def can_delete_users(_step, can_not_delete):
96
    to_delete_css = 'a.remove-user'
97
    if can_not_delete:
98 99 100
        assert world.is_css_not_present(to_delete_css)
    else:
        assert world.is_css_present(to_delete_css)
101 102


103 104
@step(u'I can(not)? add users$')
@step(u's?he can(not)? add users$')
105
def can_add_users(_step, can_not_add):
106
    add_css = 'a.create-user-button'
107
    if can_not_add:
108 109 110
        assert world.is_css_not_present(add_css)
    else:
        assert world.is_css_present(add_css)
111 112


113 114
@step(u'I can(not)? make ("([^"]*)"|myself) a course team admin$')
@step(u's?he can(not)? make ("([^"]*)"|me) a course team admin$')
115
def can_make_course_admin(_step, can_not_make_admin, outer_capture, name):
116 117 118
    if outer_capture == "myself":
        email = world.scenario_dict["USER"].email
    else:
cahrens committed
119
        email = name + '@edx.org'
120
    add_button_css = '.user-item[data-email="{email}"] .add-admin-role'.format(email=email)
121
    if can_not_make_admin:
122 123 124
        assert world.is_css_not_present(add_button_css)
    else:
        assert world.is_css_present(add_button_css)