Commit 7441e7f0 by Dean Dieker

added basic validation for registered courses in smart-accordion

parent fd841524
...@@ -3,6 +3,13 @@ Feature: There are courses on the homepage ...@@ -3,6 +3,13 @@ Feature: There are courses on the homepage
As an acceptance test As an acceptance test
I want to count all the chapters, sections, and tabs for each course I want to count all the chapters, sections, and tabs for each course
Scenario: We can see all the courses Scenario: Login to an existing account
Given I visit "http://localhost:8000/" Given I visit "http://localhost:8000/"
When I click "LOG IN"
And I login with "ddieker++@gmail.com" in the "email" field
And I login with "password" in the "password" field
And I press "Access My Courses"
Then I should see an element with class of "user" within "3" seconds
Scenario: I visit my registered courses
I verify all the content of each course I verify all the content of each course
\ No newline at end of file
...@@ -5,6 +5,7 @@ import logging ...@@ -5,6 +5,7 @@ import logging
import nose.tools import nose.tools
from selenium.webdriver import ActionChains from selenium.webdriver import ActionChains
from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support.ui import WebDriverWait
import re
## imported from lms/djangoapps/courseware/courses.py ## imported from lms/djangoapps/courseware/courses.py
from collections import defaultdict from collections import defaultdict
...@@ -27,21 +28,55 @@ from courseware.access import has_access ...@@ -27,21 +28,55 @@ from courseware.access import has_access
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from courseware.courses import course_image_url, get_course_about_section, get_course_by_id from courseware.courses import course_image_url, get_course_about_section, get_course_by_id
from courses import * from courses import *
import os.path
import sys
path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'static'))
if not path in sys.path:
sys.path.insert(1, path)
del path
from helpers import *
@step(u'I verify all the content of each course') @step(u'I verify all the content of each course')
def i_verify_all_the_content_of_each_course(step): def i_verify_all_the_content_of_each_course(step):
courses = get_courses() all_possible_courses = get_courses()
for course in courses: ids = [c.id for c in all_possible_courses]
browse_course(course) registered_courses = len(world.browser.find_elements_by_class_name("my-course"))
if len(all_possible_courses) < registered_courses:
assert False, "user is registered for more courses than are uniquely posssible"
else:
pass
i = 0
while i < registered_courses:
world.browser.find_element_by_xpath("//section[@class='my-courses']//article["+str(i+1)+"]//a").click()
wait_until_class_renders('my-courses',1)
current_course = re.sub('/info','',re.sub('.*/courses/','',world.browser.current_url))
validate_course(current_course,ids)
#
#validate_course_content(current_course)
#
world.browser.find_element_by_xpath("//a[@class='user-link']").click()
i += 1
# courses = get_courses()
# for course in courses:
# browse_course(course)
## click on a course i'm rgistered for ## click on a course i'm registered for
## extract the course id from the url ## extract the course id from the url
## match it to the course id from get_courses() and then walkthrough ## match it to the course id from get_courses() and then walkthrough
def browse_course(step,course,base_url="http://localhost:8000"): def browse_course(course_id):
for course in courses: course = get_course_by_id(course_id)
chapters = course.get_children() chapters = course.get_children()
world.browser.get(base_url+'/courses/'+course+'/courseware') world.browser.get(base_url+'/courses/'+course+'/courseware')
wait_until_id_renders('accordion',2) wait_until_id_renders('accordion',2)
...@@ -62,4 +97,12 @@ def browse_course(step,course,base_url="http://localhost:8000"): ...@@ -62,4 +97,12 @@ def browse_course(step,course,base_url="http://localhost:8000"):
while j < len(sections): while j < len(sections):
section = sections[j] section = sections[j]
course.id -> course url betwen /courses/(.*)/info # course.id -> course url betwen /courses/(.*)/info
\ No newline at end of file j += 1
def validate_course(current_course, ids):
try:
ids.index(current_course)
except:
assert False, "invalid course id"
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