Don't throw an error if library.cell_line is None.
[htsworkflow.git] / htsworkflow / frontend / samples / tests.py
index d85a46672ebc4e8902bce1a53fad6078b604ec34..5f6b7a4638800514ed5d6f46433908ff8736c041 100644 (file)
@@ -19,6 +19,7 @@ from htsworkflow.frontend.samples.views import \
      library_json
 
 from htsworkflow.frontend.auth import apidata
+from htsworkflow.util.conversion import unicode_or_none
 
 # The django test runner flushes the database between test suites not cases,
 # so to be more compatible with running via nose we flush the database tables
@@ -71,7 +72,7 @@ def create_db(obj):
 
     Library.objects.all().delete()
     obj.library_10001 = Library(
-        library_id = 10001,
+        id = "10001",
         library_name = 'C2C12 named poorly',
         library_species = obj.species_human,
         experiment_type = obj.experiment_rna_seq,
@@ -83,7 +84,7 @@ def create_db(obj):
     )
     obj.library_10001.save()
     obj.library_10002 = Library(
-        library_id = 10002,
+        id = "10002",
         library_name = 'Worm named poorly',
         library_species = obj.species_human,
         experiment_type = obj.experiment_rna_seq,
@@ -124,27 +125,26 @@ class SampleWebTestCase(TestCase):
     def test_library_info(self):
 
         for lib in Library.objects.all():
-            lib_dict = library_dict(lib.library_id)
-            url = '/samples/library/%s/json' % (lib.library_id,)
+            lib_dict = library_dict(lib.id)
+            url = '/samples/library/%s/json' % (lib.id,)
             lib_response = self.client.get(url, apidata)
             self.failUnlessEqual(lib_response.status_code, 200)
             lib_json = json.loads(lib_response.content)
 
             for d in [lib_dict, lib_json]:
                 # amplified_from_sample is a link to the library table,
-                # I want to use the "library_id" for the data lookups not
+                # I want to use the "id" for the data lookups not
                 # the embedded primary key.
                 # It gets slightly confusing on how to implement sending the right id
                 # since amplified_from_sample can be null
                 #self.failUnlessEqual(d['amplified_from_sample'], lib.amplified_from_sample)
                 self.failUnlessEqual(d['antibody_id'], lib.antibody_id)
                 self.failUnlessEqual(d['avg_lib_size'], lib.avg_lib_size)
-                self.failUnlessEqual(d['cell_line'], lib.cell_line.cellline_name)
                 self.failUnlessEqual(d['cell_line_id'], lib.cell_line_id)
+                self.failUnlessEqual(d['cell_line'], unicode_or_none(lib.cell_line))
                 self.failUnlessEqual(d['experiment_type'], lib.experiment_type.name)
                 self.failUnlessEqual(d['experiment_type_id'], lib.experiment_type_id)
                 self.failUnlessEqual(d['id'], lib.id)
-                self.failUnlessEqual(d['library_id'], lib.library_id)
                 self.failUnlessEqual(d['library_name'], lib.library_name)
                 self.failUnlessEqual(d['library_species'], lib.library_species.scientific_name)
                 self.failUnlessEqual(d['library_species_id'], lib.library_species_id)