Skip to content

Commit

Permalink
feat(scopes): expose level on api
Browse files Browse the repository at this point in the history
  • Loading branch information
czosel committed Jul 29, 2021
1 parent f5740e4 commit 3162ca4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion emeis/core/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Meta:
class ScopeSerializer(BaseSerializer):
class Meta:
model = Scope
fields = BaseSerializer.Meta.fields + ("name", "description", "parent")
fields = BaseSerializer.Meta.fields + ("name", "description", "parent", "level")


class PermissionSerializer(BaseSerializer):
Expand Down
16 changes: 16 additions & 0 deletions emeis/core/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,29 @@ def test_scope_search_filter(db, scope_factory, client):
"en": "scope2",
"fr": "",
}
assert result["data"][0]["attributes"]["level"] == 0

response = client.get(url, {"filter[search]": "scope"})
assert response.status_code == HTTP_200_OK
result = response.json()
assert len(result["data"]) == 3


def test_cannot_write_level(db, client, settings, user):
data = {
"data": {
"type": "scopes",
"attributes": {"name": {"en": "test"}, "level": 400},
}
}

resp = client.post(reverse("scope-list"), data=data)

assert resp.status_code == HTTP_201_CREATED
result = resp.json()
assert result["data"]["attributes"]["level"] == 0


def test_acl_user_filter(db, user, acl_factory, client):
acl = acl_factory(user=user)
acl_factory()
Expand Down

0 comments on commit 3162ca4

Please sign in to comment.