コード例 #1
0
 def test_datasetwrapper(self):
     from mecat.models import DatasetWrapper, Sample
     sample_desc = "My Description for Sample created in test_datasetwrapper()"
     
     sample = Sample(experiment=self.experiment, description=sample_desc)
     sample.save()
     self.assertEqual(sample.description, sample_desc)
     self.assertEqual(sample.experiment, self.experiment)
      
     from tardis.tardis_portal.models import Dataset
     dataset_desc = "My Description for Dataset created in test_datasetwrapper()"       
     dataset = Dataset(description=dataset_desc, experiment=self.experiment)
     dataset.save()
     sample_from_db = Sample.objects.get(description=sample_desc)
     dataset_from_db = Dataset.objects.get(description=dataset_desc)
     datasetwrapper = DatasetWrapper(sample=sample_from_db, dataset=dataset_from_db)
     datasetwrapper.save()
     self.assertEqual(datasetwrapper.sample, sample_from_db)
     self.assertEqual(datasetwrapper.dataset, dataset_from_db)
     
     datasetwrapper_from_db = DatasetWrapper.objects.get(sample__description=sample_desc)
     self.assertEqual(datasetwrapper_from_db.dataset.pk, dataset_from_db.pk)
     
     
     
コード例 #2
0
ファイル: views.py プロジェクト: IntersectAustralia/dc2c
def _create_wrappers_for_datasets(sample, experiment):
    datasets = experiment.dataset_set.values()
    for ds_details in datasets:
        ds_id = ds_details['id']
        # Create DatasetWrapper and assign dataset it to it
        ds = Dataset.objects.get(pk=ds_id)
        dw = DatasetWrapper(dataset=ds, sample=sample)
        dw.save()
コード例 #3
0
ファイル: test_forms.py プロジェクト: IntersectAustralia/dc2c
    def test_existing_datasetwrappers(self):
        s1 = Sample(name="s1", description="s1 description", experiment=self._create_experiment())
        s2 = Sample(name="s2", description="s2 description", experiment=self._create_experiment())
        s1.save()
        s2.save()

        d1 = DatasetWrapper(name="dw1", description="dw1 description", sample=s1)
        d2 = DatasetWrapper(name="dw2", description="dw2 description", sample=s1)
        d3 = DatasetWrapper(name="dw1", description="dw1 description", sample=s2)
        d4 = DatasetWrapper(name="dw2", description="dw2 description", sample=s1)
        d5 = DatasetWrapper(name="", description="", sample=s1)
        d1.save()
        d2.save()
        from mecat.forms import existing

        self.assertTrue(existing(d1))
        self.assertTrue(existing(d2))
        self.assertFalse(existing(d3))
        self.assertTrue(existing(d4))  # d4 is identical to d2 so it's considered existing
        self.assertFalse(existing(d5))
        d5.save()
        self.assertTrue(existing(d5))