def test_enrich_wijken(self, mock_add_cbs): enricher = GebiedenEnricher("app", "gebieden", "wijken") for entity in self.entities: enricher.enrich(entity) mock_add_cbs.assert_called_with(self.entities[2], CBS_CODES_WIJK, 'wijk')
def test_enrich_buurten(self, mock_add_cbs): enricher = GebiedenEnricher("app", "gebieden", "buurten") for entity in self.entities: enricher.enrich(entity) mock_add_cbs.assert_called_with(self.entities[2], CBS_CODES_BUURT, 'buurt')
def test_add_cbs_code_no_results_exception(self, mock_datastore): mock_datastore.return_value.query.return_value = [] enricher = GebiedenEnricher("app", "gebieden", "buurten") with self.assertRaises( GOBException, msg= f"No CBS features found for path 'gebieden/Buurten/CBScodes_buurt.xlsx'" ): enricher._add_cbs_code(self.entities[0], CBS_CODES_BUURT, 'buurt')
def test_add_cbs_code(self, mock_datastore): mock_datastore.return_value.query.return_value = [ pd.Series(["1234", "BU03630001", "Centrum"]) ] enricher = GebiedenEnricher("app", "gebieden", "buurten") enricher._add_cbs_code(self.entities[0], CBS_CODES_BUURT, 'buurt') mock_datastore.has_calls( [call.connect(), call.query(''), call.disconnect()]) # Expect cbs codes buurt self.assertEqual('BU03630001', self.entities[0]['cbs_code'])
def test_enrich_ggwgebieden(self): ggwgebieden = [{ "GGW_DOCUMENTDATUM": "YYYY-MM-DD", "BUURTEN": "1, 2, 3", "_file_info": { "last_modified": "2020-01-20T12:30:30.12345" } }] enricher = GebiedenEnricher("app", "gebieden", "ggwgebieden") for entity in ggwgebieden: enricher.enrich(entity) self.assertEqual(ggwgebieden, [{ "_IDENTIFICATIE": None, "registratiedatum": "2020-01-20T12:30:30.12345", "GGW_DOCUMENTDATUM": "YYYY-MM-DD", "BUURTEN": ["1", "2", "3"], "_file_info": { "last_modified": "2020-01-20T12:30:30.12345" } }])
def test_enriches(self): self.assertTrue(GebiedenEnricher.enriches("app", "gebieden", "wijken")) self.assertFalse( GebiedenEnricher.enriches("app", "gebieden_false", "metingen"))