3 from htsworkflow.frontend.samples.models import \
9 # The django test runner flushes the database between test suites not cases,
10 # so to be more compatible with running via nose we flush the database tables
11 # of interest before creating our sample data.
13 Species.objects.all().delete()
14 obj.species_human = Species(
15 scientific_name = 'Homo Sapeins',
16 common_name = 'human',
18 obj.species_human.save()
19 obj.species_worm = Species(
20 scientific_name = 'C. Elegans',
23 obj.species_worm.save()
24 obj.species_phix = Species(
25 scientific_name = 'PhiX',
28 obj.species_phix.save()
30 ExperimentType.objects.all().delete()
31 obj.experiment_de_novo = ExperimentType(
34 obj.experiment_de_novo.save()
35 obj.experiment_chip_seq = ExperimentType(
38 obj.experiment_chip_seq.save()
39 obj.experiment_rna_seq = ExperimentType(
42 obj.experiment_rna_seq.save()
44 Affiliation.objects.all().delete()
45 obj.affiliation_alice = Affiliation(
48 email = 'alice@some.where.else.'
50 obj.affiliation_alice.save()
51 obj.affiliation_bob = Affiliation(
53 contact = 'Other Lab Boss',
54 email = 'bob@some.where.else',
56 obj.affiliation_bob.save()
58 Library.objects.all().delete()
59 obj.library_10001 = Library(
61 library_name = 'C2C12 named poorly',
62 library_species = obj.species_human,
63 experiment_type = obj.experiment_rna_seq,
64 creation_date = datetime.datetime.now(),
65 made_for = 'scientist unit 2007',
66 made_by = 'microfludics system 7321',
67 stopping_point = '2A',
68 undiluted_concentration = '5.01',
70 obj.library_10001.save()
71 obj.library_10002 = Library(
73 library_name = 'Worm named poorly',
74 library_species = obj.species_human,
75 experiment_type = obj.experiment_rna_seq,
76 creation_date = datetime.datetime.now(),
77 made_for = 'scientist unit 2007',
78 made_by = 'microfludics system 7321',
79 stopping_point = '2A',
80 undiluted_concentration = '5.01',
82 obj.library_10002.save()
84 class LibraryTestCase(unittest.TestCase):
88 def testOrganism(self):
89 self.assertEquals(self.library_10001.organism(), 'human')
91 def testAffiliations(self):
92 self.library_10001.affiliations.add(self.affiliation_alice)
93 self.library_10002.affiliations.add(
94 self.affiliation_alice,
97 self.failUnless(len(self.library_10001.affiliations.all()), 1)
98 self.failUnless(self.library_10001.affiliation(), 'Alice')
100 self.failUnless(len(self.library_10002.affiliations.all()), 2)
101 self.failUnless(self.library_10001.affiliation(), 'Alice, Bob')