diff --git a/tests/conftest.py b/tests/conftest.py index d272b8d7..2bcb36d0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -127,9 +127,7 @@ def platform_td_big(request): yield platform -db_platform_big = pytest.fixture( - platform_td_big, scope="session", name="db_platform_big" -) +db_platform_big = pytest.fixture(platform_td_big, scope="class", name="db_platform_big") def pytest_generate_tests(metafunc): diff --git a/tests/data/test_count.py b/tests/data/test_count.py index 78bce8f7..e23b20b5 100644 --- a/tests/data/test_count.py +++ b/tests/data/test_count.py @@ -4,81 +4,77 @@ import ixmp4 -from ..fixtures import BigIamcDataset - def deepgetattr(obj, attr): return reduce(getattr, attr.split("."), obj) -big = BigIamcDataset() - - -@pytest.mark.parametrize( - "repo_name,filters", - [ - [ - "iamc.datapoints", - { - "model": {"name": "Model 0"}, - "scenario": {"name": "Scenario 0"}, - "run": {"default_only": False}, - }, - ], +class TestDataCount: + @pytest.mark.parametrize( + "repo_name,filters", [ - "iamc.datapoints", - { - "scenario": {"name__like": "Scenario *"}, - "run": {"default_only": False}, - }, - ], - [ - "iamc.datapoints", - { - "model": {"name__like": "Model *"}, - "unit": {"name__in": [f"Unit {i}" for i in range(10)]}, - "variable": {"name__like": "Variable 1*"}, - "region": {"name__in": [f"Region {i}" for i in range(10)]}, - "run": {"default_only": False}, - }, - ], - [ - "regions", - { - "name__like": "Region 1*", - "iamc": { + [ + "iamc.datapoints", + { + "model": {"name": "Model 0"}, + "scenario": {"name": "Scenario 0"}, "run": {"default_only": False}, }, - }, - ], - [ - "models", - { - "name__like": "Model *", - "iamc": True, - }, - ], - [ - "scenarios", - { - "name__like": "Scenario *", - "iamc": { - "variable": {"name__like": "Variable *"}, + ], + [ + "iamc.datapoints", + { + "scenario": {"name__like": "Scenario *"}, "run": {"default_only": False}, }, - }, - ], - [ - "units", - { - "iamc": { - "variable": {"name__like": "Variable *"}, + ], + [ + "iamc.datapoints", + { + "model": {"name__like": "Model *"}, + "unit": {"name__in": [f"Unit {i}" for i in range(10)]}, + "variable": {"name__like": "Variable 1*"}, + "region": {"name__in": [f"Region {i}" for i in range(10)]}, "run": {"default_only": False}, }, - }, + ], + [ + "regions", + { + "name__like": "Region 1*", + "iamc": { + "run": {"default_only": False}, + }, + }, + ], + [ + "models", + { + "name__like": "Model *", + "iamc": True, + }, + ], + [ + "scenarios", + { + "name__like": "Scenario *", + "iamc": { + "variable": {"name__like": "Variable *"}, + "run": {"default_only": False}, + }, + }, + ], + [ + "units", + { + "iamc": { + "variable": {"name__like": "Variable *"}, + "run": {"default_only": False}, + }, + }, + ], ], - ], -) -def test_count(db_platform_big: ixmp4.Platform, repo_name, filters): - repo = deepgetattr(db_platform_big.backend, repo_name) - assert len(repo.list(**filters)) == repo.count(**filters) + ) + def test_count(self, db_platform_big: ixmp4.Platform, repo_name, filters): + repo = deepgetattr(db_platform_big.backend, repo_name) + assert len(repo.list(**filters)) == repo.count(**filters)