#!/usr/bin/env python """Utilities for running tests.""" import os import urllib.request CACHE_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "test_data") def get_cached_level_00(num_files=2): """Get a couple real ASCII files to test against.""" file_urls = ( "https://metobs-test.ssec.wisc.edu/pub/cache/aoss/tower/level_00/version_00/2020/01/01/aoss_tower.2020-01-01.ascii", "https://metobs-test.ssec.wisc.edu/pub/cache/aoss/tower/level_00/version_00/2020/01/02/aoss_tower.2020-01-02.ascii", ) if num_files > len(file_urls): raise ValueError(f"Maximum of {len(file_urls)} can be loaded.") file_urls = file_urls[:num_files] for u in file_urls: fn = os.path.join(CACHE_DIR, os.path.basename(u)) if not os.path.isfile(fn): urllib.request.urlretrieve(u, fn) yield fn