UCSC Table Browser diff test is now implemented. I seems hacky though because of hgsid, which is assigned by the browser. We'll try this for now and change later if necessary.

This commit is contained in:
Ian Schenck
2007-01-26 19:42:40 +00:00
parent f2042bef5b
commit 07be68b0ed
2 changed files with 45 additions and 20 deletions
+24 -19
View File
@@ -196,25 +196,13 @@ class TwillTestCase(unittest.TestCase):
data = self.last_page()
file(temp_name, 'wb').write(data)
if not filecmp.cmp(local_name, temp_name):
#maybe it is just the line endings
lc = 0
for line1, line2 in zip(file(local_name), file(temp_name)):
lc += 1
line1 = line1.strip()
line2 = line2.strip()
if line1 != line2:
# nicer message
fromlines = open( local_name, 'U').readlines()
tolines = open( temp_name, 'U').readlines()
diff = difflib.unified_diff( fromlines, tolines, "local_file", "history_data" )
diff_slice = list( islice( diff, 40 ) )
if len( diff_slice ) == 40:
errmsg = [ 'Data at history id %s does not match expected, first 40 lines of diff:\n' % hid ]
else:
errmsg = [ 'Data at history id %s does not match expected, diff:\n' % hid ]
errmsg += diff_slice
raise AssertionError( "".join( errmsg ) )
try:
self.diff(local_name, temp_name)
except AssertionError, err:
errmsg = 'Data at history id %s does not match expected, diff:\n' % hid
errmsg += str( err )
raise AssertionError( errmsg )
os.remove(temp_name)
def submit_form(self, form=1, button="runtool_btn", **kwd):
@@ -272,3 +260,20 @@ class TwillTestCase(unittest.TestCase):
page = self.last_page()
if page.find('error') > -1:
raise AssertionError('Errors in the history for user %s' % self.user )
def diff(self, file1, file2):
if not filecmp.cmp(file1, file2):
#maybe it is just the line endings
lc = 0
for line1, line2 in zip(file(file1), file(file2)):
lc += 1
line1 = line1.strip()
line2 = line2.strip()
if line1 != line2:
# nicer message
fromlines = open( file1, 'U').readlines()
tolines = open( file2, 'U').readlines()
diff = difflib.unified_diff( fromlines, tolines, "local_file", "history_data" )
diff_slice = list( islice( diff, 40 ) )
raise AssertionError( "".join( diff_slice ) )
return True
+21 -1
View File
@@ -1,3 +1,4 @@
import os
from base.twilltestcase import TwillTestCase
class UcscTests(TwillTestCase):
@@ -32,7 +33,26 @@ class UcscTests(TwillTestCase):
#self.check_data('biomart_uniprot.dat')
def test_UCSC_interface(self):
"""Diffing first page of UCSC proxy."""
# hgsid needs to be set or else we get a different one every time.
self.go2myurl("http://www.genome.ucsc.edu/cgi-bin/hgTables?org=Human&db=hg18&hgsid=84962660&hgta_doMainPage=1")
current_file = self.get_fname('new_ucsc_proxy_page.dat')
diff_file = self.get_fname('ucsc_proxy_page.dat')
currentpage = self.last_page()
file(current_file, 'wb').write(currentpage)
try:
self.diff( current_file, diff_file )
except AssertionError, err:
raise AssertionError( "UCSC Page has changed:\n" + str( err ) )
# Note that execution will not reach this if there is an
# error. This is intended so that the new ucsc page will be
# stored and can be easily checked by hand and updated.
os.remove( current_file )
def test_UCSC_bed(self):
"""Getting bed files from UCSC"""