-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #277 from Limmen/foro
add unit test for csle-common
- Loading branch information
Showing
2 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
simulation-system/libs/csle-common/tests/test_management_dao.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from csle_common.dao.management.management_user import ManagementUser | ||
from csle_common.dao.management.session_token import SessionToken | ||
|
||
|
||
class TestManagementDaoSuite: | ||
""" | ||
Test suite for management data access objects (DAOs) | ||
""" | ||
|
||
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) |