def test_get_calendar(self): # nosetests -s -v dlstats.tests.fetchers.test_ecb:FetcherTestCase.test_get_calendar self._register_urls_data_tree() httpretty.register_uri( httpretty.GET, "http://www.ecb.europa.eu/press/calendars/statscal/html/index.en.html", body=body_generator(STATSCAL_FP), status=200, streaming=True, content_type="text/html", ) calendar_first = { "action": "update_node", "kwargs": {"dataset_code": "SEC", "provider_name": "ECB"}, "period_type": "date", "period_kwargs": {"run_date": datetime(2016, 1, 13, 10, 0), "timezone": pytz.timezone("CET")}, } calendar_last = { "action": "update_node", "period_type": "date", "kwargs": {"dataset_code": "IVF", "provider_name": "ECB"}, "period_kwargs": {"run_date": datetime(2017, 2, 20, 10, 0), "timezone": pytz.timezone("CET")}, } calendars = [a for a in self.fetcher.get_calendar()] self.assertEqual(len(calendars), 138) self.assertEqual(calendar_first, calendars[0]) self.assertEqual(calendar_last, calendars[-1])
def _common_test_agenda(self): httpretty.register_uri(httpretty.GET, "http://www.bis.org/statistics/relcal.htm?m=6|37|68", body=body_generator(AGENDA_FP), match_querystring=True, status=200, content_type='application/octet-stream;charset=UTF-8', streaming=True)
def _common_test_agenda(self): httpretty.register_uri( httpretty.GET, "http://www.bis.org/statistics/relcal.htm?m=6|37|68", body=body_generator(AGENDA_FP), match_querystring=True, status=200, content_type='application/octet-stream;charset=UTF-8', streaming=True)
def _register_urls_data(self, dataset_code): # ?references=all url_dataflow_for_dataset = "http://sdw-wsrest.ecb.int/service/dataflow/ECB/EXR" httpretty.register_uri( httpretty.GET, url_dataflow_for_dataset, body=body_generator(ALL_DATASETS[dataset_code]["dataflow-fp"]), match_querystring=True, status=200, streaming=True, content_type="application/vnd.sdmx.structure+xml;version=2.1", ) # Appelé par pandaSDMX quand key dans data request url_datastructure = ( "http://sdw-wsrest.ecb.int/service/datastructure/ECB/ECB_EXR1?references=children" ) # % dataset_code httpretty.register_uri( httpretty.GET, url_datastructure, body=body_generator(ALL_DATASETS[dataset_code]["datastructure-fp"]), match_querystring=True, status=200, streaming=True, content_type="application/vnd.sdmx.structure+xml;version=2.1", ) url_data = "http://sdw-wsrest.ecb.int/service/data/EXR" httpretty.register_uri( httpretty.GET, url_data, body=body_generator(ALL_DATASETS[dataset_code]["data-fp"]), match_querystring=True, status=200, streaming=True, content_type="application/vnd.sdmx.structurespecificdata+xml;version=2.1", )
def test__parse_agenda(self): # nosetests -s -v dlstats.tests.fetchers.test_ecb:FetcherTestCase.test__parse_agenda httpretty.register_uri(httpretty.GET, "http://www.ecb.europa.eu/press/calendars/statscal/html/index.en.html", body=body_generator(STATSCAL_FP), status=200, streaming=True, content_type='text/html') model = {'dataflow_key': 'BP6', 'reference_period': 'Q4 2016', 'scheduled_date': '10/04/2017 10:00 CET'} #TODO: test first and last self.assertEqual(list(self.fetcher._parse_agenda())[-1], model)
def test_get_calendar(self): # nosetests -s -v dlstats.tests.fetchers.test_ecb:FetcherTestCase.test_get_calendar dataset_code = 'EXR' self._load_files(dataset_code) httpretty.register_uri(httpretty.GET, "http://www.ecb.europa.eu/press/calendars/statscal/html/index.en.html", body=body_generator(STATSCAL_FP), status=200, streaming=True, content_type='text/html') calendar_first = { 'action': 'update-dataset', 'kwargs': {'dataset_code': 'SEC', 'provider_name': 'ECB'}, 'period_type': 'date', 'period_kwargs': { 'run_date': datetime(2016, 1, 13, 10, 0), 'timezone': 'CET' }, } calendar_last = { 'action': 'update-dataset', 'period_type': 'date', 'kwargs': {'dataset_code': 'IVF', 'provider_name': 'ECB'}, 'period_kwargs': { 'run_date': datetime(2017, 2, 20, 10, 0), 'timezone': 'CET' }, } calendars = [a for a in self.fetcher.get_calendar()] self.assertEqual(len(calendars), 138) self.assertEqual(calendar_first, calendars[0]) self.assertEqual(calendar_last, calendars[-1])