X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=blobdiff_plain;f=htsworkflow%2Ffrontend%2Fsamples%2Ftest_samples.py;h=12a4b5ba9e692366e585932ba7f7d93f8c118db7;hp=f0844e55cce7fbf3b33fbdfbf03b9d9264b3e13a;hb=refs%2Fheads%2Fpython3-django1.5;hpb=4262586d10cc0cc227390873b301b55244204c11 diff --git a/htsworkflow/frontend/samples/test_samples.py b/htsworkflow/frontend/samples/test_samples.py index f0844e5..12a4b5b 100644 --- a/htsworkflow/frontend/samples/test_samples.py +++ b/htsworkflow/frontend/samples/test_samples.py @@ -2,7 +2,7 @@ import datetime try: import json -except ImportError, e: +except ImportError as e: import simplejson as json from django.test import TestCase @@ -93,28 +93,28 @@ class SampleWebTestCase(TestCase): self.failUnlessEqual(d['stopping_point'], lib.stopping_point) self.failUnlessEqual(d['successful_pM'], lib.successful_pM) self.failUnlessEqual(d['undiluted_concentration'], - unicode(lib.undiluted_concentration)) + str(lib.undiluted_concentration)) # some specific tests if lib.id == '10981': # test a case where there is no known status - lane_set = {u'status': u'Unknown', - u'paired_end': True, - u'read_length': 75, - u'lane_number': 1, - u'lane_id': 1193, - u'flowcell': u'303TUAAXX', - u'status_code': None} + lane_set = {'status': 'Unknown', + 'paired_end': True, + 'read_length': 75, + 'lane_number': 1, + 'lane_id': 1193, + 'flowcell': '303TUAAXX', + 'status_code': None} self.failUnlessEqual(len(d['lane_set']), 1) self.failUnlessEqual(d['lane_set'][0], lane_set) elif lib.id == '11016': # test a case where there is a status - lane_set = {u'status': 'Good', - u'paired_end': True, - u'read_length': 75, - u'lane_number': 5, - u'lane_id': 1197, - u'flowcell': u'303TUAAXX', - u'status_code': 2} + lane_set = {'status': 'Good', + 'paired_end': True, + 'read_length': 75, + 'lane_number': 5, + 'lane_id': 1197, + 'flowcell': '303TUAAXX', + 'status_code': 2} self.failUnlessEqual(len(d['lane_set']), 1) self.failUnlessEqual(d['lane_set'][0], lane_set) @@ -169,11 +169,11 @@ class SampleWebTestCase(TestCase): }""" query = RDF.SPARQLQuery(body) for r in query.execute(model): - self.assertEqual(fromTypedNode(r['library_id']), u'10981') + self.assertEqual(fromTypedNode(r['library_id']), '10981') self.assertEqual(fromTypedNode(r['name']), - u'Paired End Multiplexed Sp-BAC') + 'Paired End Multiplexed Sp-BAC') self.assertEqual(fromTypedNode(r['gel_cut']), 400) - self.assertEqual(fromTypedNode(r['made_by']), u'Igor') + self.assertEqual(fromTypedNode(r['made_by']), 'Igor') state = validate_xhtml(content) if state is not None: @@ -220,7 +220,7 @@ class SampleWebTestCase(TestCase): count = 0 for r in query.execute(model): count += 1 - for name, value in r.items(): + for name, value in list(r.items()): self.assertTrue(name in bindings) self.assertTrue(value is not None) @@ -274,7 +274,7 @@ try: rdfNS = RDF.NS("http://www.w3.org/1999/02/22-rdf-syntax-ns#") xsdNS = RDF.NS("http://www.w3.org/2001/XMLSchema#") libNS = RDF.NS("http://jumpgate.caltech.edu/wiki/LibraryOntology#") -except ImportError,e: +except ImportError as e: HAVE_RDF = False @@ -300,12 +300,12 @@ class TestRDFaLibrary(TestCase): self.check_literal_object(model, ['Drosophila melanogaster'], p=libNS['species_name']) self.check_uri_object(model, - [u'http://localhost/lane/1193'], + ['http://localhost/lane/1193'], p=libNS['has_lane']) fc_uri = RDF.Uri('http://localhost/flowcell/303TUAAXX/') self.check_literal_object(model, - [u"303TUAAXX"], + ["303TUAAXX"], s=fc_uri, p=libNS['flowcell_id']) def check_literal_object(self, model, values, s=None, p=None, o=None): @@ -323,7 +323,7 @@ class TestRDFaLibrary(TestCase): self.failUnlessEqual(len(statements), len(values), "Couln't find %s %s %s" % (s,p,o)) for s in statements: - self.failUnless(unicode(s.object.uri) in values) + self.failUnless(str(s.object.uri) in values) @@ -342,7 +342,7 @@ def tearDownModule(): teardown_test_environment() def suite(): - from unittest2 import TestSuite, defaultTestLoader + from unittest import TestSuite, defaultTestLoader suite = TestSuite() suite.addTests(defaultTestLoader.loadTestsFromTestCase(LibraryTestCase)) suite.addTests(defaultTestLoader.loadTestsFromTestCase(SampleWebTestCase)) @@ -350,5 +350,5 @@ def suite(): return suite if __name__ == "__main__": - from unittest2 import main + from unittest import main main(defaultTest="suite")