Commit 271de4fb by JonahStanley

Added in testing for course team

Also modified the create_course method in common to allow for the possibility to access the course name and etc. from other files.
parent 3fe830a8
......@@ -13,6 +13,10 @@ import time
from logging import getLogger
logger = getLogger(__name__)
COURSE_NAME = 'Robot Super Course'
COURSE_NUM = '999'
COURSE_ORG = 'MITx'
########### STEP HELPERS ##############
@step('I (?:visit|access|open) the Studio homepage$')
......@@ -75,9 +79,9 @@ def create_studio_user(
def fill_in_course_info(
name='Robot Super Course',
org='MITx',
num='101'):
name=COURSE_NAME,
org=COURSE_ORG,
num=COURSE_NUM):
world.css_fill('.new-course-name', name)
world.css_fill('.new-course-org', org)
world.css_fill('.new-course-number', num)
......@@ -107,11 +111,11 @@ def log_into_studio(
def create_a_course():
c = world.CourseFactory.create(org='MITx', course='999', display_name='Robot Super Course')
c = world.CourseFactory.create(org=COURSE_ORG, course=COURSE_NUM, display_name=COURSE_NAME)
# Add the user to the instructor group of the course
# so they will have the permissions to see it in studio
g = world.GroupFactory.create(name='instructor_MITx/999/Robot_Super_Course')
g = world.GroupFactory.create(name='instructor_MITx/%s/%s' % (COURSE_NUM, COURSE_NAME.replace(" ", "_"),))
u = get_user_by_email('robot+studio@edx.org')
u.groups.add(g)
u.save()
......
Feature: Course Team
As a course author, I want to be able to add others to my team
Scenario: Users can add other users
Given I have opened a new course in Studio
And The user "abcd" exists
And I am viewing the course team settings
When I add "abcd" to the course team
And "abcd" logs in
Then He does see the course on his page
Scenario: Added users cannot delete or add other users
Given I have opened a new course in Studio
And The user "abcd" exists
And I am viewing the course team settings
When I add "abcd" to the course team
And "abcd" logs in
Then He cannot delete users
And He cannot add users
Scenario: Users can delete other users
Given I have opened a new course in Studio
And The user "abcd" exists
And I am viewing the course team settings
When I add "abcd" to the course team
And I delete "abcd" from the course team
And "abcd" logs in
Then He does not see the course on his page
Scenario: Users cannot add users that do not exist
Given I have opened a new course in Studio
And I am viewing the course team settings
When I add "abcd" to the course team
Then I should see "Could not find user by email address" somewhere on the page
#pylint: disable=C0111
#pylint: disable=W0621
from lettuce import world, step
from common import create_studio_user, COURSE_NAME
PASS = 'test'
EXTENSION = '@edx.org'
@step(u'I am viewing the course team settings')
def view_grading_settings(step):
world.click_course_settings()
link_css = 'li.nav-course-settings-team a'
world.css_click(link_css)
@step(u'The user "([^"]*)" exists$')
def create_other_user(step, name):
create_studio_user(uname=name, password=PASS, email=(name + EXTENSION))
@step(u'I add "([^"]*)" to the course team')
def add_other_user(step, name):
new_user_css = '.new-user-button'
world.css_find(new_user_css).click()
email_css = '.email-input'
f = world.css_find(email_css)
f._element.send_keys(name, EXTENSION)
confirm_css = '#add_user'
world.css_find(confirm_css).click()
@step(u'I delete "([^"]*)" from the course team')
def delete_other_user(step, name):
to_delete_css = '.remove-user[data-id="%s%s"]' % (name, EXTENSION,)
world.css_find(to_delete_css).click()
@step(u'"([^"]*)" logs in$')
def other_user_login(step, name):
world.browser.cookies.delete()
world.visit('/')
signin_css = 'a.action-signin'
world.is_css_present(signin_css)
world.css_click(signin_css)
login_form = world.browser.find_by_css('form#login_form')
login_form.find_by_name('email').fill(name + EXTENSION)
login_form.find_by_name('password').fill(PASS)
login_form.find_by_name('submit').click()
@step(u'He does( not)? see the course on his page')
def see_course(step, doesnt):
class_css = '.class-name'
all_courses = world.css_find(class_css)
all_names = [item.html for item in all_courses]
if doesnt:
assert not COURSE_NAME in all_names
else:
assert COURSE_NAME in all_names
@step(u'He cannot delete users')
def cannot_delete(step):
to_delete_css = '.remove-user'
assert world.is_css_not_present(to_delete_css)
@step(u'He cannot add users')
def cannot_add(step):
add_css = '.new-user'
assert world.is_css_not_present(add_css)
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