Commit 0b1bf15a authored by BorjaEst's avatar BorjaEst
Browse files

Add functional tests for saving

parent 95eec9d6
"""Pytest module to test sources as blackbox."""
import os
from numpy.core.fromnumeric import var
import pytest
import tests.conftest as conftest
import xarray as xr
configs = conftest.available_configurations
models = conftest.available_models
@pytest.mark.parametrize('config', configs['correct'], indirect=True)
@pytest.mark.parametrize('model', models['all'], indirect=True)
@pytest.mark.parametrize('groupby', [None, 'year', 'decade'], indirect=True)
class TestNetCDFSaving:
def test_arefiles(self, output_cd, save_netCDF, expected_netCDF):
assert all([os.path.isfile(f) for f in expected_netCDF])
def test_saved_data(self, dataset, saved_ds, variables):
xr.testing.assert_equal(dataset, saved_ds)
assert set(variables) == set(saved_ds.var())
assert set(dataset.coords) == set(saved_ds.coords)
def test_saved_attrs(self, dataset, saved_ds):
assert dataset.attrs == saved_ds.attrs
@pytest.mark.parametrize('config', configs['correct'], indirect=True)
@pytest.mark.parametrize('model', models['all'], indirect=True)
class TestMetadataFSaving:
def test_isfile(self, output_cd, save_metadata):
assert os.path.isfile("metadata.yaml")
def test_content(self, metadata, metadata_file_content):
assert metadata == metadata_file_content
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