From af4f1668d70ce35edfe2cc6df1e7079d3016927d Mon Sep 17 00:00:00 2001 From: Jay Zoldak Date: Fri, 30 Nov 2012 12:20:35 -0500 Subject: [PATCH] Stub out the video and capture the html files of the high level tabs for diff comparison Conflicts: lms/templates/video.html --- .../courseware/features/courseware_common.py | 1 + lms/djangoapps/terrain/common.py | 10 ++++ lms/djangoapps/terrain/diff_html_files.py | 57 +++++++++++++++++++ lms/templates/video.html | 26 +++++---- 4 files changed, 82 insertions(+), 12 deletions(-) create mode 100755 lms/djangoapps/terrain/diff_html_files.py diff --git a/lms/djangoapps/courseware/features/courseware_common.py b/lms/djangoapps/courseware/features/courseware_common.py index f90c7c3ba1..8850c88fef 100644 --- a/lms/djangoapps/courseware/features/courseware_common.py +++ b/lms/djangoapps/courseware/features/courseware_common.py @@ -9,6 +9,7 @@ def i_click_on_view_courseware(step): @step('I click on the "([^"]*)" tab$') def i_click_on_the_tab(step, tab): world.browser.find_link_by_text(tab).first.click() + world.save_the_html() @step('I visit the courseware URL$') def i_visit_the_course_info_url(step): diff --git a/lms/djangoapps/terrain/common.py b/lms/djangoapps/terrain/common.py index 6d5ac83d24..7294ad2a6e 100644 --- a/lms/djangoapps/terrain/common.py +++ b/lms/djangoapps/terrain/common.py @@ -7,6 +7,7 @@ from django.conf import settings from django.contrib.auth.models import User from student.models import CourseEnrollment import time +from urllib import quote_plus from nose.tools import assert_equals from logging import getLogger @@ -99,6 +100,15 @@ def log_in(email, password): # wait for the page to redraw assert world.browser.is_element_present_by_css('.content-wrapper', 10) +@world.absorb +def save_the_html(path='/tmp'): + u = world.browser.url + html = world.browser.html.encode('ascii', 'ignore') + filename = '%s.html' % quote_plus(u) + f = open('%s/%s' % (path, filename), 'w') + f.write(html) + f.close + ########### DEBUGGING ############## @step(u'I save a screenshot to "(.*)"') def save_screenshot_to(step, filename): diff --git a/lms/djangoapps/terrain/diff_html_files.py b/lms/djangoapps/terrain/diff_html_files.py new file mode 100755 index 0000000000..ce57daca57 --- /dev/null +++ b/lms/djangoapps/terrain/diff_html_files.py @@ -0,0 +1,57 @@ +""" Command line interface to difflib.py to compare html files +""" + +import sys, os, time, difflib, optparse, os.path, re +from urllib import unquote_plus + +def main(): + # Configure the option parser + usage = "usage: %prog fromdir todir" + parser = optparse.OptionParser(usage) + (options, args) = parser.parse_args() + + if len(args) == 0: + parser.print_help() + sys.exit(1) + if len(args) != 2: + parser.error("need to specify both a fromdir and todir") + + fromdir, todir = args # as specified in the usage string + + if not os.path.isdir(fromdir): + print "'%s' is not a directory" % fromdir + + if not os.path.isdir(todir): + print "'%s' is not a directory" % todir + + from_files = os.listdir(fromdir) + to_files = os.listdir(todir) + + for filename in from_files: + if filename in to_files: + + fromfile = os.path.join(fromdir, filename) + tofile = os.path.join(todir, filename) + + # we're passing these as arguments to the diff function + # fromdate = time.ctime(os.stat(fromfile).st_mtime) + # todate = time.ctime(os.stat(tofile).st_mtime) + fromlines = cleanup(open(fromfile, 'U').readlines()) + tolines = cleanup(open(tofile, 'U').readlines()) + + diff = difflib.unified_diff(fromlines, tolines, fromdir, todir, n=0) + # fromdate, todate, n=0) + + print 'FILE: %s' % unquote_plus(filename) + # we're using writelines because diff is a generator + sys.stdout.writelines(diff) + print '' + +def cleanup(lines): + + lines = [s.replace('/c4x/MITx/6.002x/asset', '/static/content-mit-6002x') for s in lines] + lines = [s.replace('handouts_', 'handouts/') for s in lines] + return lines + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/lms/templates/video.html b/lms/templates/video.html index 6e45a91c31..0270ba102e 100644 --- a/lms/templates/video.html +++ b/lms/templates/video.html @@ -2,19 +2,21 @@

${display_name}

% endif -
-
-
-
-
-
- -
-
+%if settings.MITX_FEATURES['DISPLAY_TOY_COURSES']: +
+%else: +
+
+
+
+
+
+
+
+
-
+%endif + % if source:

Download video here.