Skip to content

Commit

Permalink
[pre-commit.ci] Apply automatic pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Nov 8, 2024
1 parent f016817 commit 7980241
Showing 1 changed file with 39 additions and 30 deletions.
69 changes: 39 additions & 30 deletions conda-store-server/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# license that can be found in the LICENSE file.

import pytest
from sqlalchemy.exc import IntegrityError

from conda_store_server import api
from conda_store_server._internal.orm import NamespaceRoleMapping
Expand Down Expand Up @@ -126,42 +125,52 @@ def test_namespace_role_mapping(db):
assert len(api.list_namespaces(db).all()) == 1

# Creates role mappings with valid entity names
db.add(NamespaceRoleMapping(
namespace=namespace,
namespace_id=namespace.id,
entity="org/*",
role="editor",
))
db.add(NamespaceRoleMapping(
namespace=namespace,
namespace_id=namespace.id,
entity="*/team",
role="editor",
))
db.add(NamespaceRoleMapping(
namespace=namespace,
namespace_id=namespace.id,
entity="org/team",
role="editor",
))
db.add(NamespaceRoleMapping(
namespace=namespace,
namespace_id=namespace.id,
entity="*/*",
role="editor",
))
db.add(
NamespaceRoleMapping(
namespace=namespace,
namespace_id=namespace.id,
entity="org/*",
role="editor",
)
)
db.add(
NamespaceRoleMapping(
namespace=namespace,
namespace_id=namespace.id,
entity="*/team",
role="editor",
)
)
db.add(
NamespaceRoleMapping(
namespace=namespace,
namespace_id=namespace.id,
entity="org/team",
role="editor",
)
)
db.add(
NamespaceRoleMapping(
namespace=namespace,
namespace_id=namespace.id,
entity="*/*",
role="editor",
)
)

# Check that the namespace role mappings were correctly inserted;
# this will fail if they were not correctly instantiated.
db.commit()

# Create a role mapping with a failing entity
with pytest.raises(Exception):
db.add(NamespaceRoleMapping(
namespace=namespace,
namespace_id=namespace.id,
entity="invalid_entity_name",
))
db.add(
NamespaceRoleMapping(
namespace=namespace,
namespace_id=namespace.id,
entity="invalid_entity_name",
)
)


@pytest.mark.parametrize(
Expand Down

0 comments on commit 7980241

Please sign in to comment.