Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Branson committed Feb 11, 2021
1 parent 0473e3a commit 596847a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
24 changes: 24 additions & 0 deletions rompy/tests/data/catalog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
sources:
local_stack:
args:
fmt_fields:
dt:
- '20210210'
- '20210211'
fn_fmt: 'tab_out.nc'
hindcast: false
urlpath: '{{CATALOG_DIR}}//{dt}.000000/'
description: Test Stack Data
driver: rompy.intake.NetCDFFCStackSource

local_hindcast:
args:
fmt_fields:
dt:
- '20210210'
- '20210211'
fn_fmt: 'tab_out.nc'
hindcast: true
urlpath: '{{CATALOG_DIR}}//{dt}.000000/'
description: Test Stack Data
driver: rompy.intake.NetCDFFCStackSource
30 changes: 15 additions & 15 deletions rompy/tests/test_intake.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ def test_catalog():
assert isinstance(intake.cat.rompy_data,Catalog)


def test_intake_local():
def test_intake_local_stack():
import rompy
import intake
import os
from intake.catalog import Catalog
from intake.catalog.local import LocalCatalogEntry
import pandas as pd

mycat = Catalog.from_dict({
'test': LocalCatalogEntry('test', 'test fc stack', 'netcdf_fcstack',
args={'urlpath': os.path.dirname(os.path.abspath(__file__)) + '/data/{dt}.000000/',
'fn_fmt': 'tab_out.nc',
'fmt_fields': {'dt':list(pd.date_range('2021-02-10','2021-02-12').strftime("%Y%m%d"))},
'ds_filters': {'subset':['hs']},
'hindcast':False}),
})
ds = mycat.test.to_dask()
mycat = intake.open_catalog(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data','catalog.yaml'))
ds = mycat.local_stack.to_dask()

assert ds.time.shape == (2,121)

def test_intake_local_hindcast():
import rompy
import intake
import os

mycat = intake.open_catalog(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data','catalog.yaml'))
ds = mycat.local_hindcast.to_dask()

assert ds.time.shape == (145,)

def test_intake_remote_stack():
import rompy
Expand All @@ -55,7 +55,7 @@ def test_intake_remote_hindcast():
assert ds.time.shape == (193,)


# if __name__ == '__main__':
if __name__ == '__main__':
# test_intake_remote_stack()
# test_intake_remote_hindcast()
# test_intake_local()
test_intake_local()

0 comments on commit 596847a

Please sign in to comment.