Skip to content

Commit

Permalink
Add scope="class" to fixtures in test_permissions.py
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentCauchois authored and bouttier committed May 4, 2023
1 parent 4a91429 commit 558f349
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions backend/geonature/tests/test_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
from pypnusershub.db.models import User


@pytest.fixture
@pytest.fixture(scope="class")
def actions():
return {action.code_action: action for action in TActions.query.all()}


@pytest.fixture
@pytest.fixture(scope="class")
def scopes():
scope_type = BibFiltersType.query.filter_by(code_filter_type="SCOPE").one()
return {f.value_filter: f for f in TFilters.query.filter_by(filter_type=scope_type).all()}
Expand All @@ -38,45 +38,45 @@ def create_module(label):
)


@pytest.fixture
@pytest.fixture(scope="class")
def module_gn():
return TModules.query.filter_by(module_code="GEONATURE").one()


@pytest.fixture
@pytest.fixture(scope="class")
def object_all():
return TObjects.query.filter_by(code_object="ALL").one()


@pytest.fixture
@pytest.fixture(scope="class")
def object_a():
obj = TObjects(code_object="object_a")
return obj


@pytest.fixture
@pytest.fixture(scope="class")
def object_b():
obj = TObjects(code_object="object_b")
return obj


@pytest.fixture
@pytest.fixture(scope="class")
def module_a():
with db.session.begin_nested():
module = create_module("module_a")
db.session.add(module)
return module


@pytest.fixture
@pytest.fixture(scope="class")
def module_b():
with db.session.begin_nested():
module = create_module("module_b")
db.session.add(module)
return module


@pytest.fixture
@pytest.fixture()
def groups():
groups = {
"g1": User(groupe=True),
Expand All @@ -88,7 +88,7 @@ def groups():
return groups


@pytest.fixture
@pytest.fixture()
def roles(groups):
roles = {
"r1": User(),
Expand Down Expand Up @@ -118,7 +118,7 @@ def cruved_dict(scopes):
}


@pytest.fixture
@pytest.fixture()
def permissions(roles, groups, actions, scopes):
roles = ChainMap(roles, groups)

Expand All @@ -135,7 +135,7 @@ def _permissions(role, cruved, **kwargs):
return _permissions


@pytest.fixture
@pytest.fixture()
def assert_cruved(roles):
def _assert_cruved(role, cruved, module=None, object=None):
role = roles[role]
Expand Down

0 comments on commit 558f349

Please sign in to comment.