Esempio n. 1
0
 def test_read_not_empty(self, mock_container_list):
     mock_container_list.return_value = [{"name": "name"}]
     config = {
         "container": "container",
         "file_filter": ".*",
         "file_type": None
     }
     store = ObjectDatastore(config)
     data = store.query(None)
     self.assertEqual(list(data), [{"name": "name"}])
Esempio n. 2
0
 def test_read_from_uva2(self, mock_container_list, mock_object):
     mock_container_list.return_value = [{"name": "name"}]
     config = {
         "container": "container",
         "file_filter": ".*",
         "file_type": "UVA2"
     }
     store = ObjectDatastore({}, config)
     store._read_uva2 = MagicMock(return_value=[])
     data = list(store.query(None))
     self.assertEqual(data, [])
     store._read_uva2.assert_called()
Esempio n. 3
0
 def test_read_from_xls(self, mock_container_list, mock_object):
     mock_container_list.return_value = [{"name": "name"}]
     config = {
         "container": "container",
         "file_filter": ".*",
         "file_type": "XLS"
     }
     store = ObjectDatastore({}, config)
     store._read_xls = MagicMock(return_value=[])
     data = store.query(None)
     self.assertEqual(list(data), [])
     store._read_xls.assert_called()
Esempio n. 4
0
def _get_cbs_features(path: str) -> dict[str, dict[str, str]]:
    """
    Gets the CBS codes from the Objectstore and returns a list of dicts with the naam,
    code (wijk or buurt).

    :param path: the path to source file
    :return: a list of dicts with CBS Code and CBS naam, mapped on the local code.
    """
    datastore = ObjectDatastore(
        connection_config=get_datastore_config("Basisinformatie"),
        read_config={
            "file_filter": path,
            "file_type": "XLS"
        })

    datastore.connect()
    result = list(datastore.query(''))
    datastore.disconnect()

    if not result:
        raise GOBException(f"No CBS features found for path '{path}'")

    return {row[0]: {"code": row[1], "naam": row[2]} for row in result}
Esempio n. 5
0
 def test_read(self, mock_container_list):
     store = ObjectDatastore(self.config)
     data = store.query(None)
     self.assertEqual(list(data), [])
     mock_container_list.assert_called()