Skip to content

Commit

Permalink
try class scope for big td
Browse files Browse the repository at this point in the history
  • Loading branch information
meksor committed Aug 12, 2024
1 parent 4f73122 commit ecf94b7
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 68 deletions.
4 changes: 1 addition & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
126 changes: 61 additions & 65 deletions tests/data/test_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit ecf94b7

Please sign in to comment.