예제 #1
0
    def test_update_boundary_dataset(self):
        store.dropAll()
        bds = BoundaryDataSet("id")
        boundaries = [
            'O23P12P34S56', 'P10P11P2', 'N0', 'N8O2P0', 'O6S0S1S2', 'Q'
        ]

        for boundary in boundaries:
            bds.add(Boundary(boundary_ID=BoundaryID(boundary)), Data(""))
        store.insert(bds)

        bds2 = BoundaryDataSet("id")
        boundaries2 = ['N0', 'N8O2P0', 'O6S0S1S2', 'Q']

        for boundary in boundaries2:
            bds2.add(Boundary(boundary_ID=BoundaryID(boundary)), Data(""))
        store.update_boundary_dataset(bds2)

        stored_bds = store.query_by_boundary_dataset_id("id")
        num_bds = 0
        num_boundaries = 0
        for bds in stored_bds:
            for boundary in bds.get_boundaries():
                assert boundaries2.__contains__(boundary.AUID_to_CUIDs())
                num_boundaries = num_boundaries + 1
            num_bds = num_bds + 1
        self.assertEqual(num_bds, 1)
        self.assertEqual(num_boundaries, len(boundaries2))
        store.dropAll()
예제 #2
0
    def test_delete_boundary_in_boundary_datasets(self):
        store.dropAll()
        bds = BoundaryDataSet("id")
        boundaries = [
            'O23P12P34S56', 'P10P11P2', 'N0', 'N8O2P0', 'O6S0S1S2', 'Q'
        ]

        for boundary in boundaries:
            bds.add(Boundary(boundary_ID=BoundaryID(boundary)), Data(""))
        store.insert(bds)

        deleted_boundaries = store.delete_boundary_in_boundary_datasets(
            "id", (Boundary(boundary_ID=BoundaryID('O23P12P34S56'))))
        self.assertEqual(deleted_boundaries, 1)

        stored_bds = store.query_by_boundary_in_boundary_datasets(
            "id", (Boundary(boundary_ID=BoundaryID('O23P12P34S56'))))
        num_bds = 0
        for bds in stored_bds:
            assert bds.get_boundaries().__len__() == 0
            num_bds = num_bds + 1
        assert num_bds == 1
        self.assertEqual(num_bds, 1)

        store.dropAll()
예제 #3
0
    def test_get_boundaries(self):
        boundary1 = OptimalBoundary(cells=[
            CellID('N'),
            CellID('O0'),
            CellID('P123'),
            CellID('S34567')
        ])
        boundary2 = OptimalBoundary(cells=[CellID('O35'), CellID('P234')])
        boundary3 = OptimalBoundary(cells=[CellID('S034'), CellID('S57')])
        data = Data('')

        b_ds = {
            boundary1.boundary_ID.value: (boundary1, data),
            boundary2.boundary_ID.value: (boundary2, data),
            boundary3.boundary_ID.value: (boundary3, data)
        }
        b_dataset = BoundaryDataSet('id', b_ds)

        boundaries = b_dataset.get_boundaries()

        self.assertEqual(boundaries, [boundary1, boundary2, boundary3])