-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for
coriolisclient.v1.licensing_server.py
module
- Loading branch information
1 parent
1844992
commit b14cf98
Showing
1 changed file
with
39 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright 2024 Cloudbase Solutions Srl | ||
# All Rights Reserved. | ||
|
||
from unittest import mock | ||
|
||
from coriolisclient.tests import test_base | ||
from coriolisclient.v1 import licensing | ||
from coriolisclient.v1 import licensing_server | ||
|
||
|
||
class LicensingServerManagerTestCase( | ||
test_base.CoriolisBaseTestCase): | ||
"""Test suite for the Coriolis v1 Licensing Server Manager.""" | ||
|
||
@mock.patch.object(licensing, 'LicensingClient') | ||
def setUp(self, mock_LicensingClient): | ||
mock_client = mock.Mock() | ||
self.mock_licencing_client = mock.Mock() | ||
mock_LicensingClient.return_value = self.mock_licencing_client | ||
super(LicensingServerManagerTestCase, self).setUp() | ||
self.licence = licensing_server.LicensingServerManager( | ||
mock_client) | ||
|
||
def test_status(self): | ||
mock_resource_class = mock.Mock() | ||
self.licence.resource_class = mock_resource_class | ||
|
||
result = self.licence.status() | ||
|
||
self.assertEqual( | ||
mock_resource_class.return_value, | ||
result | ||
) | ||
self.mock_licencing_client.get.assert_called_once_with( | ||
'/status', | ||
response_key='status') | ||
mock_resource_class.assert_called_once_with( | ||
self.licence, self.mock_licencing_client.get.return_value, | ||
loaded=True) |