Skip to content

Commit

Permalink
Merge pull request #1 from alvindera97/dev
Browse files Browse the repository at this point in the history
Add Role Enum
  • Loading branch information
alvindera97 authored Jun 17, 2024
2 parents 3b7467e + 9aa1590 commit 08cbe4f
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
3 changes: 3 additions & 0 deletions role/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from role.role import Roles

Role = Roles
18 changes: 18 additions & 0 deletions role/role.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""
Roles module.
This module contains class and method definitions for the [user/client] Role
object.
Classes:
Roles: Provides definitions for the [user/client] role object and it's functionalities.
"""
from enum import Enum


class Roles(Enum):
"""
Enum class definition of [user/client] role.
"""
PUBLISHER = 1
SUBSCRIBER = 2
35 changes: 35 additions & 0 deletions tests/roles/test_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,31 @@
setUp(): Prepares test environment before each individual test.
tearDown(): Cleans up test environment after each test.
"""
import inspect
import unittest
from enum import Enum

from role import Role


class TestRolesTestCase(unittest.TestCase):
"""
Test case class for tests for user roles.
"""

@classmethod
def setUpClass(cls):
"""
Method defining executions before starting of tests in the class.
Differs from self.setUp() as self.setUp() is called before every test
while self.setUpClass() is called before start of all the tests in the
class exactly once.
:return:
"""
super().setUpClass()
cls.role = Role

def setUp(self) -> None:
"""
Method defining what must be run before each individual test.
Expand All @@ -32,6 +49,24 @@ def teatDown(self) -> None:
"""
super().tearDown()

def test_role_enum_class_exists(self) -> None:
"""
Tests if the Role enum class exists.
:return: None
"""
self.assertTrue(inspect.isclass(Role))

def test_role_is_an_enum_instance_is_of_roles_class(self):
"""
Tests if the role object is of type Enum class
:return: None
"""
self.assertEqual(type(self.role), type(Enum))

def test_role_enum_has_both_publisher_and_subscriber_representation_entities(self):
self.assertEqual(self.role.PUBLISHER.value, 1)
self.assertEqual(self.role.SUBSCRIBER.value, 2)


if __name__ == "__main__":
unittest.main()

0 comments on commit 08cbe4f

Please sign in to comment.