Skip to content

Commit

Permalink
fix tests + add test
Browse files Browse the repository at this point in the history
  • Loading branch information
haakonvt committed Dec 4, 2023
1 parent 34061cb commit 22eda3e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/tests_unit/test_data_classes/test_capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,13 @@ def test_create_capability_forget_initializing_scope(self):
assert grp1.dump() == grp2.dump()

def test_create_capability_forget_initializing_scope__not_supported(self):
with pytest.raises(ValueError, match="^DataSetsAcl got an unknown scope"):
with pytest.raises(ValueError, match="DataSetsAcl got an unknown scope"):
DataSetsAcl(actions=[DataSetsAcl.Action.Read], scope=CurrentUserScope)

with pytest.raises(ValueError, match="^DataSetsAcl got an unknown scope"):
with pytest.raises(ValueError, match="DataSetsAcl got an unknown scope"):
DataSetsAcl(actions=[DataSetsAcl.Action.Read], scope=GroupsAcl.Scope.CurrentUser)

with pytest.raises(ValueError, match="^ExperimentsAcl got an unknown scope"):
with pytest.raises(ValueError, match="ExperimentsAcl got an unknown scope"):
ExperimentsAcl(actions=[ExperimentsAcl.Action.Use], scope=AllScope)


Expand Down Expand Up @@ -412,8 +412,8 @@ def test_idscopes_camel_case():
with pytest.raises(ValueError) as err:
Capability.load(dct)
assert err.value.args[0].startswith(
"DataSetsAcl got an unknown scope: IDScopeLowerCase(ids=[2495]), expected an instance of one of: "
"[DataSetsAcl.Scope.All, DataSetsAcl.Scope.ID]"
"Could not instantiate DataSetsAcl due to: DataSetsAcl got an unknown scope: IDScopeLowerCase(ids=[2495]), "
"expected an instance of one of: [DataSetsAcl.Scope.All, DataSetsAcl.Scope.ID]"
)


Expand Down
5 changes: 5 additions & 0 deletions tests/tests_unit/test_data_classes/test_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest

from cognite.client.data_classes import Group, GroupList
from cognite.client.data_classes.capabilities import DataModelInstancesAcl


def raw_groups():
Expand Down Expand Up @@ -39,6 +40,10 @@ def raw_groups():


class TestGroups:
def test_group_init__accept_single_acl(self) -> None:
acl = DataModelInstancesAcl([DataModelInstancesAcl.Action.Write], DataModelInstancesAcl.Scope.All())
assert Group(name="a", capabilities=acl) == Group(name="a", capabilities=[acl])

@pytest.mark.parametrize("raw", list(raw_groups()))
def test_load_dump_unknown_group(self, raw: dict[str, Any]) -> None:
group = Group.load(raw)
Expand Down

0 comments on commit 22eda3e

Please sign in to comment.