import json
except ImportError, e:
import simplejson as json
+from datetime import timedelta
import os
import shutil
import sys
NSMAP = {'libns':'http://jumpgate.caltech.edu/wiki/LibraryOntology#'}
from django.db import connection
-OLD_DB_NAME = settings.DATABASE_NAME
-VERBOSITY = 0
-def setUpModule():
- setup_test_environment()
- settings.DEBUG = False
- connection.creation.create_test_db(VERBOSITY)
-
-def tearDownModule():
- connection.creation.destroy_test_db(OLD_DB_NAME, VERBOSITY)
- teardown_test_environment()
class ClusterStationTestCases(TestCase):
- fixtures = ['test_flowcells.json']
+ fixtures = ['initial_data.json',
+ 'test_flowcells.json']
def test_default(self):
c = models.ClusterStation.default()
class SequencerTestCases(TestCase):
- fixtures = ['test_flowcells.json']
+ fixtures = ['initial_data.json',
+ 'test_flowcells.json']
def test_default(self):
# starting with no default
class ExperimentsTestCases(TestCase):
- fixtures = ['test_flowcells.json',
+ fixtures = ['initial_data.json',
+ 'test_flowcells.json',
]
def setUp(self):
tree = fromstring(response.content)
flowcell_spans = tree.xpath('//span[@property="libns:flowcell_id"]',
namespaces=NSMAP)
- self.assertEqual(flowcell_spans[0].text, '30012AAXX (failed)')
- failed_fc_span = flowcell_spans[0]
+ self.assertEqual(flowcell_spans[1].text, '30012AAXX (failed)')
+ failed_fc_span = flowcell_spans[1]
failed_fc_a = failed_fc_span.getparent()
# make sure some of our RDF made it.
self.assertEqual(failed_fc_a.get('typeof'), 'libns:IlluminaFlowcell')
self.assertTrue(library_id in expected[lane_id])
self.assertEqual(count, 10)
+ def test_flowcell_estimates(self):
+ classic_flowcell = models.FlowCell.objects.get(pk=153)
+ classic_mid = experiments.estimateFlowcellDuration(classic_flowcell)
+
+ self.assertEqual(classic_mid, timedelta(4, 44000))
+
+ rapid_flowcell = models.FlowCell.objects.get(pk=300)
+ rapid_mid = experiments.estimateFlowcellDuration(rapid_flowcell)
+ self.assertEqual(rapid_mid, timedelta(seconds=60800))
+
+ def test_round_to_days(self):
+ data = [
+ [timedelta(2, 12345), (timedelta(days=2), timedelta(days=3))],
+ [timedelta(0, 345), (timedelta(days=0), timedelta(days=1))],
+ ]
+
+ for estimate, expected in data:
+ rounded = experiments.roundToDays(estimate)
+ self.assertEqual(rounded, expected)
class TestFileType(TestCase):
+ fixtures = ['initial_data.json',
+ 'test_flowcells.json',
+ ]
+
def test_file_type_unicode(self):
file_type_objects = models.FileType.objects
name = 'QSEQ tarfile'
self.assertEqual(result.get('end', None), end)
class TestEmailNotify(TestCase):
- fixtures = ['test_flowcells.json']
+ fixtures = ['initial_data.json',
+ 'test_flowcells.json']
def test_started_email_not_logged_in(self):
response = self.client.get('/experiments/started/153/')
return dict( ((x['library_id'],x) for x in lane) )
class TestSequencer(TestCase):
- fixtures = ['test_flowcells.json',
+ fixtures = ['initial_data.json',
+ 'test_flowcells.json',
]
def test_name_generation(self):
errmsgs = list(inference.run_validation())
self.assertEqual(len(errmsgs), 0)
-
-OLD_DB = settings.DATABASES['default']['NAME']
-def setUpModule():
- setup_test_environment()
- connection.creation.create_test_db()
-
-def tearDownModule():
- connection.creation.destroy_test_db(OLD_DB)
- teardown_test_environment()
-
def suite():
- from unittest2 import TestSuite, defaultTestLoader
+ from unittest import TestSuite, defaultTestLoader
suite = TestSuite()
for testcase in [ClusterStationTestCases,
SequencerTestCases,
return suite
if __name__ == "__main__":
- from unittest2 import main
+ from unittest import main
main(defaultTest="suite")