Explicitly list initial_data.json for the test data loader fixtures
[htsworkflow.git] / htsworkflow / frontend / samples / test_samples.py
index d64499d2d911ef201aecb9000407e25964314205..791bf059984bc72e902f0fc2543818f0f38784f2 100644 (file)
@@ -1,5 +1,4 @@
 import datetime
-import unittest
 
 try:
     import json
@@ -7,6 +6,10 @@ except ImportError, e:
     import simplejson as json
 
 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.samples.models import \
         Affiliation, \
@@ -23,7 +26,8 @@ from htsworkflow.util.conversion import unicode_or_none
 from htsworkflow.util.ethelp import validate_xhtml
 
 class LibraryTestCase(TestCase):
-    fixtures = ['test_samples.json']
+    fixtures = ['initial_data.json',
+                'test_samples.json']
 
     def setUp(self):
         create_db(self)
@@ -49,7 +53,8 @@ class SampleWebTestCase(TestCase):
     Test returning data from our database in rest like ways.
     (like returning json objects)
     """
-    fixtures = ['test_samples.json']
+    fixtures = ['initial_data.json',
+                'test_samples.json']
 
     def test_library_info(self):
         for lib in Library.objects.all():
@@ -181,9 +186,7 @@ class SampleWebTestCase(TestCase):
         from htsworkflow.util.rdfinfer import Infer
         add_default_schemas(model)
         inference = Infer(model)
-        ignored = {'Missing type for: http://localhost/'}
-        errmsgs = [msg for msg in inference.run_validation()
-                   if msg not in ignored ]
+        errmsgs = list(inference.run_validation())
         self.assertEqual(len(errmsgs), 0)
 
     def test_library_index_rdfa(self):
@@ -200,9 +203,7 @@ class SampleWebTestCase(TestCase):
         self.assertEqual(response.status_code, 200)
         load_string_into_model(model, 'rdfa', response.content)
 
-        ignored = {'Missing type for: http://localhost/'}
-        errmsgs = [msg for msg in inference.run_validation()
-                   if msg not in ignored ]
+        errmsgs = list(inference.run_validation())
         self.assertEqual(len(errmsgs), 0)
 
         body =  """prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@@ -216,7 +217,7 @@ class SampleWebTestCase(TestCase):
                       ?species libns:species_name ?species_name . }
            OPTIONAL { ?library libns:name ?name . }
         }"""
-        bindings = {'library', 'library_id', 'name', 'species', 'species_name'}
+        bindings = set(['library', 'library_id', 'name', 'species', 'species_name'])
         query = RDF.SPARQLQuery(body)
         count = 0
         for r in query.execute(model):
@@ -280,7 +281,8 @@ except ImportError,e:
 
 
 class TestRDFaLibrary(TestCase):
-    fixtures = ['test_samples.json']
+    fixtures = ['initial_data.json',
+                'test_samples.json']
 
     def test_parse_rdfa(self):
         model = get_rdf_memory_model()
@@ -332,3 +334,15 @@ def get_rdf_memory_model():
     storage = RDF.MemoryStorage()
     model = RDF.Model(storage)
     return model
+
+def suite():
+    from unittest2 import TestSuite, defaultTestLoader
+    suite = TestSuite()
+    suite.addTests(defaultTestLoader.loadTestsFromTestCase(LibraryTestCase))
+    suite.addTests(defaultTestLoader.loadTestsFromTestCase(SampleWebTestCase))
+    suite.addTests(defaultTestLoader.loadTestsFromTestCase(TestRDFaLibrary))
+    return suite
+
+if __name__ == "__main__":
+    from unittest2 import main
+    main(defaultTest="suite")