Exemplo n.º 1
0
    def test_schema_persistence_unit(self):
        """This test creates a simple schema hierarchy, and tests updates, etc"""
        unit = UnitOfWork(None)
        ids = []

        schema1 = DataEntrySchema("base1")
        schema1.addAttr(FileDataType("file"))
        ids.append(unit.post(schema1))

        schema2 = DataEntrySchema("child1")
        schema2.addAttr(FileDataType("file2"))
        schema2.extends.append(schema1.id)
        ids.append(unit.post(schema2))

        ret = self.service.commit(unit, None)

        for obj in ret:
            self.assertGreater(obj.id, 0)
            self.assertIn(obj.correlationid, ids)
Exemplo n.º 2
0
    def test_dataset_data_source_unit(self):
        """This test creates a simple schema hierarchy, and tests updates, etc"""
        unit = UnitOfWork(None)

        schema1 = DataEntrySchema("base1")
        schema1.addAttr(FileDataType("file"))
        schema_id = unit.post(schema1)

        loc = Location(10.0, 11.0)
        loc.name = "Location"
        loc_id = unit.post(loc)

        dataset1 = Dataset()
        dataset1.schema = schema_id
        dataset1.location = loc_id
        dataset1_id = unit.post(dataset1)

        dataset2 = Dataset()
        dataset2.schema = schema_id
        dataset2.location = loc_id
        dataset2.data_source = DatasetDataSource(dataset1_id, "")
        dataset2_id = unit.post(dataset2)

        ret = self.service.commit(unit, None)

        found = False
        for r in ret:
            if isinstance(r, Dataset) and dataset1_id == r.correlationid:
                dataset1_id = r.id
            elif isinstance(r, Dataset) and dataset2_id == r.correlationid:
                self.assertEquals(dataset1_id, r.data_source.dataset_id,
                                  "Data source dataset_id was not updated")
                found = True

        self.assertTrue(
            found, "Didn't find the dataset with the dataset data source")