diff --git a/forcingprocessor/tests/test_forcingprocessor.py b/forcingprocessor/tests/test_forcingprocessor.py index 686ba472..dbada157 100644 --- a/forcingprocessor/tests/test_forcingprocessor.py +++ b/forcingprocessor/tests/test_forcingprocessor.py @@ -1,6 +1,7 @@ import pytest, os from pathlib import Path from datetime import datetime +import requests from forcingprocessor.forcingprocessor import prep_ngen_data from forcingprocessor.nwm_filenames_generator import generate_nwmfiles @@ -39,8 +40,8 @@ def get_time(): def test_generate_filenames(get_paths, get_time): conf = { "forcing_type" : "operational_archive", - "start_date" : "202310300000", - "end_date" : "202310300000", + "start_date" : "", + "end_date" : "", "runinput" : 1, "varinput" : 5, "geoinput" : 1, @@ -93,10 +94,47 @@ def test_processor(get_time, get_paths): } } - prep_ngen_data(conf) - - tarball = (pytest.data_dir/pytest.date/"forcings/forcings.tar.gz").resolve() - assert tarball.exists() + nwmurl_conf = { + "forcing_type" : "operational_archive", + "start_date" : "", + "end_date" : "", + "runinput" : 1, + "varinput" : 5, + "geoinput" : 1, + "meminput" : 0, + "urlbaseinput" : 7, + "fcst_cycle" : [0], + "lead_time" : [1] + } + nwmurl_conf['start_date'] = pytest.date + pytest.hourminute + nwmurl_conf['end_date'] = pytest.date + pytest.hourminute + + for jurl in [1,2,3,5,6,7,8,9]: + nwmurl_conf["urlbaseinput"] = jurl + + generate_nwmfiles(nwmurl_conf) + + with open(pytest.filenamelist,'r') as fp: + for jline in fp.readlines(): + web_address = jline.strip() + break + + if web_address.find('https://') >= 0: + response = requests.get(web_address) + if response.status_code != 200: + print(f'{jline} doesn\'t exist!') + pass + else: + print(f'{jline} exists! Testing with forcingprocessor') + + prep_ngen_data(conf) + + tarball = (pytest.data_dir/pytest.date/"forcings/forcings.tar.gz").resolve() + assert tarball.exists() + os.remove(tarball) + else: + # in bucket, implement bucket checks for files + pass