From 1f68ade38e8d3694e7e64f98282ed3eab09feac6 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 24 Nov 2022 11:36:42 +0300 Subject: tests: Add test for `create_resource` * gn3/auth/authorisation/resources.py: Define Resource and ResourceCategory classes. Create the `create_resource` stub. * tests/unit/auth/test_resources.py: test for `create_resource` function --- gn3/auth/authorisation/resources.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 gn3/auth/authorisation/resources.py (limited to 'gn3') diff --git a/gn3/auth/authorisation/resources.py b/gn3/auth/authorisation/resources.py new file mode 100644 index 0000000..d01c435 --- /dev/null +++ b/gn3/auth/authorisation/resources.py @@ -0,0 +1,27 @@ +"""Handle the management of resources.""" +from uuid import UUID +from typing import NamedTuple + +from gn3.auth import db +from .groups import Group +from .checks import authorised_p + +class ResourceCategory(NamedTuple): + """Class representing a resource category.""" + resource_category_id: UUID + resource_category_key: str + resource_category_description: str + +class Resource(NamedTuple): + """Class representing a resource.""" + group: Group + resource_id: UUID + resource_name: str + resource_category: ResourceCategory + +@authorised_p(("create-resource",), error_message="Could not create resource") +def create_resource( + conn: db.DbConnection, resource_name: str, + resource_category: ResourceCategory): + """Create a resource item.""" + return tuple() -- cgit v1.2.3