Example #1
0
class TestIdMapperByCode(unittest.TestCase):
    def setUp(self):
        h5py_file = h5py.File(grid_file, "r")
        self.id_mapper = IdMapper(H5pyGroup(h5py_file, "mappings")["id_map"])

    def test_get_channels_by_code(self):
        tc = TYPE_CODE_MAP["v2_channel"]
        qs = self.id_mapper.get_by_code(tc)
        assert np.all(qs["obj_code"] == tc)

    def test_get_culvert_by_code(self):
        tc = TYPE_CODE_MAP["v2_culvert"]
        qs = self.id_mapper.get_by_code(tc)
        assert np.all(qs["obj_code"] == tc)
Example #2
0
def test_init_idMapper(mocked_id_map, h5py_file, threedi_datasource):
    mocked_id_map.return_value = simple_id_map()
    IdMapper.prepare_mapper(h5py_file, threedi_datasource)
    mapper = IdMapper(h5py_file["mappings"]["id_map"])
    assert mapper.get_by_code(TYPE_CODE_MAP["v2_channel"]).size == NODE_LENGTH
    assert mapper.get_by_name("v2_channel").size == NODE_LENGTH