Skip to content

Commit

Permalink
add unit test for csle-common
Browse files Browse the repository at this point in the history
  • Loading branch information
foroughsh committed Aug 29, 2023
1 parent 9928bf5 commit b1df314
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions simulation-system/libs/csle-common/tests/test_jobs_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
from csle_common.dao.simulation_config.simulation_trace import SimulationTrace
from csle_common.dao.training.agent_type import AgentType
from csle_common.dao.training.player_type import PlayerType
from csle_common.dao.management.management_user import ManagementUser
from csle_common.dao.management.session_token import SessionToken


class TestJobsDaoSuite:
Expand Down Expand Up @@ -176,3 +178,37 @@ def test_training_job_config(self) -> None:
training_job_config.to_dict())
assert (TrainingJobConfig.from_dict(training_job_config.to_dict()) ==
training_job_config)

def test_management_user(self) -> None:
"""
Tests creation and dict conversion of the ManagementUser DAO
:return: None
"""

management_user = ManagementUser(username="test1", password="test2", email="[email protected]", first_name="test3",
last_name="test4", organization="testi", admin=False, salt="test")

assert isinstance(management_user.to_dict(), dict)
assert isinstance(ManagementUser.from_dict(management_user.to_dict()),
ManagementUser)
assert (ManagementUser.from_dict(management_user.to_dict()).to_dict() ==
management_user.to_dict())
assert (ManagementUser.from_dict(management_user.to_dict()) ==
management_user)

def test_session_token(self) -> None:
"""
Tests creation and dict conversion of the SessionToken DAO
:return: None
"""

session_token = SessionToken(token="test_token", timestamp=11.11, username="test")
assert isinstance(session_token.to_dict(), dict)
assert isinstance(SessionToken.from_dict(session_token.to_dict()),
SessionToken)
assert (SessionToken.from_dict(session_token.to_dict()).to_dict() ==
session_token.to_dict())
assert (SessionToken.from_dict(session_token.to_dict()) ==
session_token)

0 comments on commit b1df314

Please sign in to comment.