Merge pull request #241 from edx/ned/delete-unused-test-code
Remove the unused smart-accordion lettuce feature, and the code it used.
This commit is contained in:
@@ -13,8 +13,6 @@ from student.models import CourseEnrollment
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from xmodule.contentstore.django import contentstore
|
||||
from xmodule.templates import update_templates
|
||||
from bs4 import BeautifulSoup
|
||||
import os.path
|
||||
from urllib import quote_plus
|
||||
|
||||
|
||||
@@ -76,50 +74,6 @@ def register_by_course_id(course_id, is_staff=False):
|
||||
CourseEnrollment.objects.get_or_create(user=u, course_id=course_id)
|
||||
|
||||
|
||||
|
||||
@world.absorb
|
||||
def save_the_course_content(path='/tmp'):
|
||||
html = world.browser.html.encode('ascii', 'ignore')
|
||||
soup = BeautifulSoup(html)
|
||||
|
||||
# get rid of the header, we only want to compare the body
|
||||
soup.head.decompose()
|
||||
|
||||
# for now, remove the data-id attributes, because they are
|
||||
# causing mismatches between cms-master and master
|
||||
for item in soup.find_all(attrs={'data-id': re.compile('.*')}):
|
||||
del item['data-id']
|
||||
|
||||
# we also need to remove them from unrendered problems,
|
||||
# where they are contained in the text of divs instead of
|
||||
# in attributes of tags
|
||||
# Be careful of whether or not it was the last attribute
|
||||
# and needs a trailing space
|
||||
for item in soup.find_all(text=re.compile(' data-id=".*?" ')):
|
||||
s = unicode(item.string)
|
||||
item.string.replace_with(re.sub(' data-id=".*?" ', ' ', s))
|
||||
|
||||
for item in soup.find_all(text=re.compile(' data-id=".*?"')):
|
||||
s = unicode(item.string)
|
||||
item.string.replace_with(re.sub(' data-id=".*?"', ' ', s))
|
||||
|
||||
# prettify the html so it will compare better, with
|
||||
# each HTML tag on its own line
|
||||
output = soup.prettify()
|
||||
|
||||
# use string slicing to grab everything after 'courseware/' in the URL
|
||||
u = world.browser.url
|
||||
section_url = u[u.find('courseware/') + 11:]
|
||||
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
|
||||
filename = '%s.html' % (quote_plus(section_url))
|
||||
f = open('%s/%s' % (path, filename), 'w')
|
||||
f.write(output)
|
||||
f.close
|
||||
|
||||
|
||||
@world.absorb
|
||||
def clear_courses():
|
||||
# Flush and initialize the module store
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
# Here are all the courses for Fall 2012
|
||||
# MITx/3.091x/2012_Fall
|
||||
# MITx/6.002x/2012_Fall
|
||||
# MITx/6.00x/2012_Fall
|
||||
# HarvardX/CS50x/2012 (we will not be testing this, as it is anomolistic)
|
||||
# HarvardX/PH207x/2012_Fall
|
||||
# BerkeleyX/CS169.1x/2012_Fall
|
||||
# BerkeleyX/CS169.2x/2012_Fall
|
||||
# BerkeleyX/CS184.1x/2012_Fall
|
||||
|
||||
#You can load the courses into your data directory with these cmds:
|
||||
# git clone https://github.com/MITx/3.091x.git
|
||||
# git clone https://github.com/MITx/6.00x.git
|
||||
# git clone https://github.com/MITx/content-mit-6002x.git
|
||||
# git clone https://github.com/MITx/content-mit-6002x.git
|
||||
# git clone https://github.com/MITx/content-harvard-id270x.git
|
||||
# git clone https://github.com/MITx/content-berkeley-cs169x.git
|
||||
# git clone https://github.com/MITx/content-berkeley-cs169.2x.git
|
||||
# git clone https://github.com/MITx/content-berkeley-cs184x.git
|
||||
|
||||
Feature: There are courses on the homepage
|
||||
In order to compared rendered content to the database
|
||||
As an acceptance test
|
||||
I want to count all the chapters, sections, and tabs for each course
|
||||
|
||||
# Commenting these all out for now because they don't always run,
|
||||
# they have too many prerequesites, e.g. the course exists, and
|
||||
# is within the start and end dates, etc.
|
||||
|
||||
# Scenario: Navigate through course MITx/3.091x/2012_Fall
|
||||
# Given I am registered for course "MITx/3.091x/2012_Fall"
|
||||
# And I log in
|
||||
# Then I verify all the content of each course
|
||||
|
||||
# Scenario: Navigate through course MITx/6.002x/2012_Fall
|
||||
# Given I am registered for course "MITx/6.002x/2012_Fall"
|
||||
# And I log in
|
||||
# Then I verify all the content of each course
|
||||
|
||||
# Scenario: Navigate through course MITx/6.00x/2012_Fall
|
||||
# Given I am registered for course "MITx/6.00x/2012_Fall"
|
||||
# And I log in
|
||||
# Then I verify all the content of each course
|
||||
|
||||
# Scenario: Navigate through course HarvardX/PH207x/2012_Fall
|
||||
# Given I am registered for course "HarvardX/PH207x/2012_Fall"
|
||||
# And I log in
|
||||
# Then I verify all the content of each course
|
||||
|
||||
# Scenario: Navigate through course BerkeleyX/CS169.1x/2012_Fall
|
||||
# Given I am registered for course "BerkeleyX/CS169.1x/2012_Fall"
|
||||
# And I log in
|
||||
# Then I verify all the content of each course
|
||||
|
||||
# Scenario: Navigate through course BerkeleyX/CS169.2x/2012_Fall
|
||||
# Given I am registered for course "BerkeleyX/CS169.2x/2012_Fall"
|
||||
# And I log in
|
||||
# Then I verify all the content of each course
|
||||
|
||||
# Scenario: Navigate through course BerkeleyX/CS184.1x/2012_Fall
|
||||
# Given I am registered for course "BerkeleyX/CS184.1x/2012_Fall"
|
||||
# And I log in
|
||||
# Then I verify all the content of each course
|
||||
@@ -1,158 +0,0 @@
|
||||
#pylint: disable=C0111
|
||||
#pylint: disable=W0621
|
||||
|
||||
from lettuce import world, step
|
||||
from re import sub
|
||||
from nose.tools import assert_equals
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from common import *
|
||||
|
||||
from logging import getLogger
|
||||
logger = getLogger(__name__)
|
||||
|
||||
|
||||
def check_for_errors():
|
||||
e = world.browser.find_by_css('.outside-app')
|
||||
if len(e) > 0:
|
||||
assert False, 'there was a server error at %s' % (world.browser.url)
|
||||
else:
|
||||
assert True
|
||||
|
||||
|
||||
@step(u'I verify all the content of each course')
|
||||
def i_verify_all_the_content_of_each_course(step):
|
||||
all_possible_courses = get_courses()
|
||||
logger.debug('Courses found:')
|
||||
for c in all_possible_courses:
|
||||
logger.debug(c.id)
|
||||
ids = [c.id for c in all_possible_courses]
|
||||
|
||||
# Get a list of all the registered courses
|
||||
registered_courses = world.browser.find_by_css('article.my-course')
|
||||
if len(all_possible_courses) < len(registered_courses):
|
||||
assert False, "user is registered for more courses than are uniquely posssible"
|
||||
else:
|
||||
pass
|
||||
|
||||
for test_course in registered_courses:
|
||||
test_course.css_click('a')
|
||||
check_for_errors()
|
||||
|
||||
# Get the course. E.g. 'MITx/6.002x/2012_Fall'
|
||||
current_course = sub('/info', '', sub('.*/courses/', '', world.browser.url))
|
||||
validate_course(current_course, ids)
|
||||
|
||||
world.click_link('Courseware')
|
||||
assert world.is_css_present('accordion')
|
||||
check_for_errors()
|
||||
browse_course(current_course)
|
||||
|
||||
# clicking the user link gets you back to the user's home page
|
||||
world.css_click('.user-link')
|
||||
check_for_errors()
|
||||
|
||||
|
||||
def browse_course(course_id):
|
||||
|
||||
## count chapters from xml and page and compare
|
||||
chapters = get_courseware_with_tabs(course_id)
|
||||
num_chapters = len(chapters)
|
||||
|
||||
rendered_chapters = world.browser.find_by_css('#accordion > nav > div')
|
||||
num_rendered_chapters = len(rendered_chapters)
|
||||
|
||||
msg = '%d chapters expected, %d chapters found on page for %s' % (num_chapters, num_rendered_chapters, course_id)
|
||||
#logger.debug(msg)
|
||||
assert num_chapters == num_rendered_chapters, msg
|
||||
|
||||
chapter_it = 0
|
||||
|
||||
## Iterate the chapters
|
||||
while chapter_it < num_chapters:
|
||||
|
||||
## click into a chapter
|
||||
world.browser.find_by_css('#accordion > nav > div')[chapter_it].find_by_tag('h3').click()
|
||||
|
||||
## look for the "there was a server error" div
|
||||
check_for_errors()
|
||||
|
||||
## count sections from xml and page and compare
|
||||
sections = chapters[chapter_it]['sections']
|
||||
num_sections = len(sections)
|
||||
|
||||
rendered_sections = world.browser.find_by_css('#accordion > nav > div')[chapter_it].find_by_tag('li')
|
||||
num_rendered_sections = len(rendered_sections)
|
||||
|
||||
msg = ('%d sections expected, %d sections found on page, %s - %d - %s' %
|
||||
(num_sections, num_rendered_sections, course_id, chapter_it, chapters[chapter_it]['chapter_name']))
|
||||
#logger.debug(msg)
|
||||
assert num_sections == num_rendered_sections, msg
|
||||
|
||||
section_it = 0
|
||||
|
||||
## Iterate the sections
|
||||
while section_it < num_sections:
|
||||
|
||||
## click on a section
|
||||
world.browser.find_by_css('#accordion > nav > div')[chapter_it].find_by_tag('li')[section_it].find_by_tag('a').click()
|
||||
|
||||
## sometimes the course-content takes a long time to load
|
||||
assert world.is_css_present('.course-content')
|
||||
|
||||
## look for server error div
|
||||
check_for_errors()
|
||||
|
||||
## count tabs from xml and page and compare
|
||||
|
||||
## count the number of tabs. If number of tabs is 0, there won't be anything rendered
|
||||
## so we explicitly set rendered_tabs because otherwise find_elements returns a None object with no length
|
||||
num_tabs = sections[section_it]['clickable_tab_count']
|
||||
if num_tabs != 0:
|
||||
rendered_tabs = world.browser.find_by_css('ol#sequence-list > li')
|
||||
num_rendered_tabs = len(rendered_tabs)
|
||||
else:
|
||||
rendered_tabs = 0
|
||||
num_rendered_tabs = 0
|
||||
|
||||
msg = ('%d tabs expected, %d tabs found, %s - %d - %s' %
|
||||
(num_tabs, num_rendered_tabs, course_id, section_it, sections[section_it]['section_name']))
|
||||
#logger.debug(msg)
|
||||
|
||||
# Save the HTML to a file for later comparison
|
||||
world.save_the_course_content('/tmp/%s' % course_id)
|
||||
|
||||
assert num_tabs == num_rendered_tabs, msg
|
||||
|
||||
tabs = sections[section_it]['tabs']
|
||||
tab_it = 0
|
||||
|
||||
## Iterate the tabs
|
||||
while tab_it < num_tabs:
|
||||
|
||||
rendered_tabs[tab_it].find_by_tag('a').click()
|
||||
|
||||
## do something with the tab sections[section_it]
|
||||
# e = world.browser.find_by_css('section.course-content section')
|
||||
# process_section(e)
|
||||
tab_children = tabs[tab_it]['children_count']
|
||||
tab_class = tabs[tab_it]['class']
|
||||
if tab_children != 0:
|
||||
rendered_items = world.browser.find_by_css('div#seq_content > section > ol > li > section')
|
||||
num_rendered_items = len(rendered_items)
|
||||
msg = ('%d items expected, %d items found, %s - %d - %s - tab %d' %
|
||||
(tab_children, num_rendered_items, course_id, section_it, sections[section_it]['section_name'], tab_it))
|
||||
#logger.debug(msg)
|
||||
assert tab_children == num_rendered_items, msg
|
||||
|
||||
tab_it += 1
|
||||
|
||||
section_it += 1
|
||||
|
||||
chapter_it += 1
|
||||
|
||||
|
||||
def validate_course(current_course, ids):
|
||||
try:
|
||||
ids.index(current_course)
|
||||
except:
|
||||
assert False, "invalid course id %s" % current_course
|
||||
Reference in New Issue
Block a user