Exemplo n.º 1
0
 def test_unit_of_work_roundtrip(self):
     unit = UnitOfWork(None)
     loc = Location(10, 11)
     loc.name = "Loc 1"
     unit.insert(loc)
     unit_dict = self.marshaller.obj_to_dict(unit)
     self.assertEquals("unit_of_work", unit_dict["class"])
     
     unit2 = self.marshaller.dict_to_obj(unit_dict)
     self.assertEquals(10.0, unit2._to_insert[0].latitude)
     self.assertEquals(11.0, unit2._to_insert[0].longitude)
Exemplo n.º 2
0
    def test_unit_of_work_roundtrip(self):
        unit = UnitOfWork(None)
        loc = Location(10, 11)
        loc.name = "Loc 1"
        unit.insert(loc)
        unit_dict = self.marshaller.obj_to_dict(unit)
        self.assertEquals("unit_of_work", unit_dict["class"])

        unit2 = self.marshaller.dict_to_obj(unit_dict)
        self.assertEquals(10.0, unit2._to_insert[0].latitude)
        self.assertEquals(11.0, unit2._to_insert[0].longitude)
Exemplo n.º 3
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.º 4
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")
Exemplo n.º 5
0
 def test_unit_of_work_validation(self):
     unit = UnitOfWork(None)
     loc = Location(10, 11)
     self.assertRaises(InvalidObjectError, unit.insert, loc)
     loc.name = "test"
     unit.insert(loc) # Should work now.
Exemplo n.º 6
0
 def test_unit_of_work_validation(self):
     unit = UnitOfWork(None)
     loc = Location(10, 11)
     self.assertRaises(InvalidObjectError, unit.insert, loc)
     loc.name = "test"
     unit.insert(loc)  # Should work now.