Commit 18feb139 by Mark L. Chang

first test from django with lettuce + selenium

parent ad284bb5
...@@ -2,9 +2,11 @@ from lettuce import * #before, world ...@@ -2,9 +2,11 @@ from lettuce import * #before, world
from selenium import * from selenium import *
import lettuce_webdriver.webdriver import lettuce_webdriver.webdriver
import logging import logging
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
## imported from lms/djangoapps/courseware/courses.py
from collections import defaultdict from collections import defaultdict
from fs.errors import ResourceNotFoundError from fs.errors import ResourceNotFoundError
from functools import wraps from functools import wraps
...@@ -20,9 +22,10 @@ from xmodule.modulestore.django import modulestore ...@@ -20,9 +22,10 @@ from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.modulestore.exceptions import ItemNotFoundError
from static_replace import replace_urls, try_staticfiles_lookup from static_replace import replace_urls, try_staticfiles_lookup
from courseware.access import has_access from courseware.access import has_access
## end import
## set up logger from django.core.urlresolvers import reverse
# logging.basicConfig(filename='lettuce.log', level=logging.DEBUG) from courseware.courses import course_image_url, get_course_about_section
## support functions ## support functions
def get_courses(): def get_courses():
...@@ -30,15 +33,20 @@ def get_courses(): ...@@ -30,15 +33,20 @@ def get_courses():
Returns dict of lists of courses available, keyed by course.org (ie university). Returns dict of lists of courses available, keyed by course.org (ie university).
Courses are sorted by course.number. Courses are sorted by course.number.
''' '''
# TODO: Clean up how 'error' is done.
# filter out any courses that errored.
courses = [c for c in modulestore().get_courses() courses = [c for c in modulestore().get_courses()
if isinstance(c, CourseDescriptor)] if isinstance(c, CourseDescriptor)]
courses = sorted(courses, key=lambda course: course.number) courses = sorted(courses, key=lambda course: course.number)
logging.info("COURSES FOUND")
logging.info(courses)
logging.debug(courses) return courses
## course listing step ## course listing step
@step(u'I should see all courses') @step(u'I should see all courses')
def i_should_see_all_courses(step): def i_should_see_all_courses(step):
get_courses() courses = get_courses()
\ No newline at end of file page_source = world.browser.page_source
course_link_texts = [ (c.location.course, c.display_name) for c in courses]
for c in course_link_texts:
assert world.browser.find_element_by_partial_link_text(c[0] + ' ' + c[1])
Feature: There are courses Feature: There are courses on the homepage
In order to view and sign up for courses In order to view and sign up for courses
As anonymous web users As anonymous web users
We want to be able to see all the courses available on the home page We want to be able to see all the courses available on the home page
......
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