Skip to content

Commit

Permalink
TST: add warning test
Browse files Browse the repository at this point in the history
  • Loading branch information
jklenzing committed Oct 31, 2023
1 parent 6825a0d commit 058ab05
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pysatNASA/tests/test_methods_cdaweb.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 058ab05

Please sign in to comment.