Remove django test environment setup code.
[htsworkflow.git] / htsworkflow / frontend / experiments / test_experiments.py
index 0f241476e78ff7938145337bb64409accfa69a04..11214b1163ad4fb2a4b6a7de1879cc8095847a97 100644 (file)
@@ -14,6 +14,9 @@ from django.conf import settings
 from django.core import mail
 from django.core.exceptions import ObjectDoesNotExist
 from django.test import TestCase
+from django.test.utils import setup_test_environment, teardown_test_environment
+from django.db import connection
+from django.conf import settings
 from htsworkflow.frontend.experiments import models
 from htsworkflow.frontend.experiments import experiments
 from htsworkflow.frontend.auth import apidata
@@ -25,6 +28,8 @@ LANE_SET = range(1,9)
 
 NSMAP = {'libns':'http://jumpgate.caltech.edu/wiki/LibraryOntology#'}
 
+from django.db import connection
+
 class ClusterStationTestCases(TestCase):
     fixtures = ['test_flowcells.json']
 
@@ -479,10 +484,9 @@ class TestFileType(TestCase):
         file_type_objects = models.FileType.objects
         name = 'QSEQ tarfile'
         file_type_object = file_type_objects.get(name=name)
-        self.assertEqual(u"<FileType: QSEQ tarfile>",
+        self.assertEqual(u"QSEQ tarfile",
                              unicode(file_type_object))
 
-class TestFileType(TestCase):
     def test_find_file_type(self):
         file_type_objects = models.FileType.objects
         cases = [('woldlab_090921_HWUSI-EAS627_0009_42FC3AAXX_l7_r1.tar.bz2',
@@ -561,10 +565,11 @@ class TestEmailNotify(TestCase):
         response = self.client.get('/experiments/started/153/', {'send':'1','bcc':'on'})
         self.assertEqual(response.status_code, 200)
         self.assertEqual(len(mail.outbox), 4)
-        bcc = set(settings.NOTIFICATION_BCC).intersect(set(settings.MANAGERS))
+        bcc = set(settings.NOTIFICATION_BCC).copy()
+        bcc.update(set(settings.MANAGERS))
         for m in mail.outbox:
             self.assertTrue(len(m.body) > 0)
-            self.assertEqual(m.bcc, bcc)
+            self.assertEqual(set(m.bcc), bcc)
 
     def test_email_navigation(self):
         """
@@ -648,9 +653,7 @@ class TestSequencer(TestCase):
         load_string_into_model(model, 'rdfa', response.content)
 
         errmsgs = list(inference.run_validation())
-        self.assertEqual(len(errmsgs), 2)
-        for errmsg in errmsgs:
-            self.assertEqual(errmsg, 'Missing type for: http://localhost/')
+        self.assertEqual(len(errmsgs), 0)
 
     def test_lane_with_rdf_validation(self):
         from htsworkflow.util.rdfhelp import add_default_schemas, \
@@ -672,6 +675,20 @@ class TestSequencer(TestCase):
         load_string_into_model(model, 'rdfa', response.content)
 
         errmsgs = list(inference.run_validation())
-        self.assertEqual(len(errmsgs), 2)
-        for errmsg in errmsgs:
-            self.assertEqual(errmsg, 'Missing type for: http://localhost/')
+        self.assertEqual(len(errmsgs), 0)
+
+def suite():
+    from unittest2 import TestSuite, defaultTestLoader
+    suite = TestSuite()
+    for testcase in [ClusterStationTestCases,
+                     SequencerTestCases,
+                     ExerimentsTestCases,
+                     TestFileType,
+                     TestEmailNotify,
+                     TestSequencer]:
+        suite.addTests(defaultTestLoader.loadTestsFromTestCase(testcase))
+    return suite
+
+if __name__ == "__main__":
+    from unittest2 import main
+    main(defaultTest="suite")