def test_download_fail(self, database): url = f"{Config.METEO_FRANCE_NIVO_BASE_URL}/nivo.20190812.csv" responses.add(responses.GET, url, status=503) with connection_scope(database.engine) as con: with pytest.raises(HTTPError): download_nivo( NivoDate(is_archive=False, nivo_date=date(2019, 8, 12)), con)
def test_recent_nivo_download(self): url = f"{Config.METEO_FRANCE_NIVO_BASE_URL}/nivo.20190812.csv" with open(os.path.join(CURRENT_DIR, "test_data/nivo.20190812.csv")) as f: responses.add(responses.GET, url, body=f.read(), content_type="text/plain") r = download_nivo( NivoDate(is_archive=False, nivo_date=date(2019, 8, 12))) assert isinstance(r, NivoCsv) assert r.nivo_date == date(2019, 8, 12)
def test_archive_download(self): url = f"{Config.METEO_FRANCE_NIVO_BASE_URL}/Archive/nivo.201701.csv.gz" with open(os.path.join(CURRENT_DIR, "test_data/nivo.201701.csv.gz"), "rb") as f: responses.add(responses.GET, url, body=f.read(), content_type="application/x-gzip") r = download_nivo(NivoDate(is_archive=True, nivo_date=date(2017, 1, 1))) assert isinstance(r, ArchiveNivoCss) assert r.nivo_date == date(2017, 1, 1)
def test_download_fail(self): url = f"{Config.METEO_FRANCE_NIVO_BASE_URL}/nivo.20190812.csv" responses.add(responses.GET, url, status=503) with pytest.raises(HTTPError): download_nivo( NivoDate(is_archive=False, nivo_date=date(2019, 8, 12)))