コード例 #1
0
    def test_update_cell_in_cell_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)

        store.update_boundary_in_boundary_datasets(
            "id", (Boundary(boundary_ID=BoundaryID('O23P12P34S56'))),
            Data("test"))

        stored_bds = store.query_by_boundary_in_boundary_datasets(
            "id", (Boundary(boundary_ID=BoundaryID('O23P12P34S56'))))
        num_bds = 0
        num_boundaries = 0
        for bds in stored_bds:
            for boundary, data in bds.get_boundaries_and_data():
                assert boundaries.__contains__(boundary.AUID_to_CUIDs())
                assert data.content == Data("test").content
                num_boundaries = num_boundaries + 1
            num_bds = num_bds + 1
        self.assertEqual(num_bds, 1)
        self.assertEqual(num_boundaries, 1)
        store.dropAll()
コード例 #2
0
    def test_get_boundaries_and_data(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_data = b_dataset.get_boundaries_and_data()

        self.assertEqual(boundaries_data,
                         [(boundary1, data), (boundary2, data),
                          (boundary3, data)])