Skip to content

Commit

Permalink
Ensure Path variables are input to functions as str
Browse files Browse the repository at this point in the history
  • Loading branch information
cassandra-elmer authored Jul 11, 2024
1 parent d36f204 commit 2e67254
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tests/test_seaexplorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ def test_merge_rawnc():
result_default = seaexplorer.merge_parquet(
'tests/data/realtime_rawnc/',
'tests/data/realtime_rawnc/',
example_dir / 'example-seaexplorer/deploymentRealtime.yml')
str(example_dir / 'example-seaexplorer/deploymentRealtime.yml'))

result_sub = seaexplorer.merge_parquet(
'tests/data/realtime_rawnc/',
'tests/data/realtime_rawnc/',
example_dir / 'example-seaexplorer/deploymentRealtime.yml',
str(example_dir / 'example-seaexplorer/deploymentRealtime.yml'),
kind='sub')
assert result_default is False
assert result_sub is True
Expand Down Expand Up @@ -91,35 +91,35 @@ def test_raw_to_timeseries():
with pytest.raises(FileNotFoundError) as missing_file_exc:
result_default = seaexplorer.raw_to_timeseries('tests/data/realtime_rawnc/',
'tests/data/l0-profiles/',
example_dir / 'example-seaexplorer/deploymentRealtime.yml',
str(example_dir / 'example-seaexplorer/deploymentRealtime.yml'),
)
result_sub = seaexplorer.raw_to_timeseries('tests/data/realtime_rawnc/',
'tests/data/l0-profiles/',
example_dir / 'example-seaexplorer/deploymentRealtime.yml',
str(example_dir / 'example-seaexplorer/deploymentRealtime.yml'),
kind='sub')
assert 'No such file or directory' in str(missing_file_exc)
assert result_sub == 'tests/data/l0-profiles/dfo-eva035-20190718.nc'


def test_missing_bad_timebase():
# Prepare yaml files with bad timebase and no timebase
with open(example_dir / 'example-seaexplorer/deploymentRealtime.yml') as fin:
with open(str(example_dir / 'example-seaexplorer/deploymentRealtime.yml')) as fin:
deployment = yaml.safe_load(fin)
deployment['netcdf_variables']['timebase']['source'] = "non existing sensor"
with open(example_dir / 'example-seaexplorer/bad_timebase.yml', "w") as fin:
with open(str(example_dir / 'example-seaexplorer/bad_timebase.yml'), "w") as fin:
yaml.dump(deployment, fin)
deployment['netcdf_variables'].pop('timebase')
with open(example_dir / 'example-seaexplorer/no_timebase.yml', "w") as fin:
with open(str(example_dir / 'example-seaexplorer/no_timebase.yml'), "w") as fin:
yaml.dump(deployment, fin)
with pytest.raises(ValueError) as bad_timebase_exc:
result_bad_timebase = seaexplorer.raw_to_timeseries('tests/data/realtime_rawnc/',
'tests/data/l0-profiles/',
example_dir / 'example-seaexplorer/bad_timebase.yml',
str(example_dir / 'example-seaexplorer/bad_timebase.yml'),
kind='sub')
with pytest.raises(ValueError) as no_timebase_exc:
result_no_timebase = seaexplorer.raw_to_timeseries('tests/data/realtime_rawnc/',
'tests/data/l0-profiles/',
example_dir / 'example-seaexplorer/no_timebase.yml',
str(example_dir / 'example-seaexplorer/no_timebase.yml'),
kind='sub')
assert "sensor not found in pld1 columns" in str(bad_timebase_exc)
assert "Must specify timebase" in str(no_timebase_exc)

0 comments on commit 2e67254

Please sign in to comment.