Skip to content

Commit

Permalink
extract tiles tests
Browse files Browse the repository at this point in the history
  • Loading branch information
John-Sharples committed Sep 21, 2023
1 parent 25e5dab commit ee83356
Showing 1 changed file with 34 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# !/usr/bin/env python3

import pytest

from unittest import mock
import os
import datetime

from metplus.wrappers.extract_tiles_wrapper import ExtractTilesWrapper

import metplus.wrappers.extract_tiles_wrapper as etw

def extract_tiles_wrapper(metplus_config):
config = metplus_config
Expand Down Expand Up @@ -34,23 +34,48 @@ def extract_tiles_wrapper(metplus_config):
config.set('config', 'EXTRACT_TILES_OUTPUT_DIR',
'{OUTPUT_BASE}/extract_tiles')

config.set('config','FCST_EXTRACT_TILES_INPUT_TEMPLATE', '{INPUT_BASE}/fcst{lead?fmt=%HHH}.grb2')
config.set('config','OBS_EXTRACT_TILES_INPUT_TEMPLATE', '{INPUT_BASE}/obs{lead?fmt=%HHH}.grb2')
config.set('config','FCST_EXTRACT_TILES_OUTPUT_TEMPLATE', 'fcst_out.nc')
config.set('config','OBS_EXTRACT_TILES_OUTPUT_TEMPLATE', 'obs_out.nc')
config.set('config','FCST_EXTRACT_TILES_INPUT_DIR', '{INPUT_BASE}/fcst_tiles')
config.set('config','OBS_EXTRACT_TILES_INPUT_DIR', '{INPUT_BASE}/obs_tiles')

config.set('config','FCST_VAR1_NAME','TMP')
config.set('config','FCST_VAR1_LEVELS', 'Z2')
config.set('config','OBS_VAR1_NAME', 'TMP')
config.set('config','OBS_VAR1_LEVELS', 'Z2')

wrapper = ExtractTilesWrapper(config)
return wrapper

@pytest.mark.parametrize(
'tool_config',[(
'tool_config,storm_dict',[(
#TC stat
{
'EXTRACT_TILES_TC_STAT_INPUT_TEMPLATE': '{INPUT_BASE}/filter_{init?fmt=%Y%m%d}.tcst'
}
)
'EXTRACT_TILES_TC_STAT_INPUT_TEMPLATE': 'filter_{init?fmt=%Y%m%d}.tcst',
'EXTRACT_TILES_TC_STAT_INPUT_DIR': '{INPUT_BASE}',
},
{'header':'the header', 'ID1':['A','B']}),
#MDT
({
'EXTRACT_TILES_MTD_INPUT_TEMPLATE': 'filter_{init?fmt=%Y%m%d}.tcst',
'EXTRACT_TILES_MTD_INPUT_DIR': '{INPUT_BASE}'
},
{'header':'the header', 'ID1':['A','B']}),
]
)
def test_run_extract_tiles(metplus_config, tool_config):
def test_run_extract_tiles(metplus_config, tool_config, storm_dict):
config = metplus_config
for key, value in tool_config.items():
config.set('config', key, value)
wrapper = extract_tiles_wrapper(config)
wrapper.run_all_times()

with mock.patch.object(etw.os.path, "exists"):
with mock.patch.object(etw, "get_storms", return_value=storm_dict):
wrapper = extract_tiles_wrapper(config)
import pdb;pdb.set_trace()
wrapper.run_all_times()
print(wrapper)
assert wrapper.isOK


Expand Down

0 comments on commit ee83356

Please sign in to comment.