Skip to content

Commit

Permalink
tests for each web address in nwmurl
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanLaserGit committed Dec 29, 2023
1 parent 0985fe9 commit e4d320a
Showing 1 changed file with 44 additions and 6 deletions.
50 changes: 44 additions & 6 deletions forcingprocessor/tests/test_forcingprocessor.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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



Expand Down

0 comments on commit e4d320a

Please sign in to comment.