diff --git a/pysatNASA/tests/test_methods_cdaweb.py b/pysatNASA/tests/test_methods_cdaweb.py index dd7870e6..6bd8c407 100644 --- a/pysatNASA/tests/test_methods_cdaweb.py +++ b/pysatNASA/tests/test_methods_cdaweb.py @@ -1,8 +1,10 @@ """Unit tests for the cdaweb instrument methods.""" import datetime as dt +import logging import pandas as pds import requests +import tempfile import pytest @@ -50,6 +52,28 @@ def test_load_with_empty_file_list(self): assert meta is None return + def test_bad_zip_warning_get_files(self, caplog): + """Test that warning is raised for unsupported zip method.""" + + # Specifiy small file to get + url = 'https://cdaweb.gsfc.nasa.gov/pub/000_readme.txt' + req = requests.get(url) + + # Download to temporary location + temp_dir = tempfile.TemporaryDirectory() + + with caplog.at_level(logging.WARNING, logger='pysat'): + cdw.get_file(req.content, '.', 'test.txt', temp_path=temp_dir.name, + zip_method='badzip') + captured = caplog.text + + # Check for appropriate warning + warn_msg = "not a recognized zip method" + assert warn_msg in captured + + return + + @pytest.mark.parametrize("bad_key,bad_val,err_msg", [("tag", "badval", "inst_id / tag combo unknown."), ("inst_id", "badval",