Commit 5c81b442 authored by Marco Kurzynski's avatar Marco Kurzynski
Browse files

WIP compare.py test

parent d0b1ba41
from utils import file_finder
from utils import compare
import os
from netCDF4 import Dataset
FILL_STRING = "foo"
......@@ -42,6 +44,12 @@ def test_file_finder(tmp_path):
for k in found_files.keys():
assert(sorted(expected_files[k]) == sorted(found_files[k]))
# check getFiles with extensions
found_files = file_finder.getFiles(dirs[0], extensions=[".RNC", ".CXS"])
expected_files = {str(dirs[0]):(f"file1_{dirs[0].name[2:]}.RNC", f"file3_{dirs[0].name[2:]}.CXS")}
for k in found_files.keys():
assert(sorted(expected_files[k]) == sorted(found_files[k]))
# run on a single file
# create single file
f = tmp_path / "just_a_file.txt"
......@@ -56,3 +64,19 @@ def test_file_finder(tmp_path):
found_files = file_finder.getFiles(str(f))
expected_files = {os.path.dirname(f) : (str(f.name),)}
assert(found_files == expected_files)
def test_dimensions(tmp_path, capsys):
# test nc
nc_files = [Dataset(str(tmp_path / "nc1.nc"), mode="w"), Dataset(str(tmp_path / "nc2.nc"), mode="w")]
# make dimensions with different shapes
nc_files[0].createDimension("dim1", None) # unlimited
nc_files[1].createDimension("dim1", 1)
for f in nc_files: f.sync()
ret = compare.main(argv=[str(tmp_path / "nc1.nc"), str(tmp_path / "nc2.nc")])
captured = capsys.readouterr()
print(f"return val: {ret}")
assert 0
assert 'Dimension dim1 sizes do not match' in captured.out
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment