-
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.endpoint_storage
module
- Loading branch information
1 parent
e289841
commit a536819
Showing
1 changed file
with
63 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,63 @@ | ||
# Copyright 2024 Cloudbase Solutions Srl | ||
# All Rights Reserved. | ||
|
||
from unittest import mock | ||
|
||
from coriolisclient.tests import test_base | ||
from coriolisclient.v1 import endpoint_storage | ||
|
||
|
||
class EndpointStorageManagerTestCase( | ||
test_base.CoriolisBaseTestCase): | ||
"""Test suite for the Coriolis v1 Endpoint Storage Manager.""" | ||
|
||
def setUp(self): | ||
mock_client = mock.Mock() | ||
super(EndpointStorageManagerTestCase, self).setUp() | ||
self.endpoint = endpoint_storage.EndpointStorageManager(mock_client) | ||
|
||
@mock.patch.object(endpoint_storage.EndpointStorageManager, '_list') | ||
def test_list( | ||
self, | ||
mock_list | ||
): | ||
mock_endpoint = mock.Mock() | ||
mock_endpoint.uuid = '53773ab8-1474-4cf7-bf0c-a496a6595ecb' | ||
|
||
result = self.endpoint.list( | ||
mock_endpoint, | ||
{"env": "mock_env"} | ||
) | ||
|
||
self.assertEqual( | ||
mock_list.return_value, | ||
result | ||
) | ||
mock_list.assert_called_once_with( | ||
('/endpoints/53773ab8-1474-4cf7-bf0c-a496a6595ecb/storage' | ||
'?env=eyJlbnYiOiAibW9ja19lbnYifQ=='), | ||
'storage', | ||
values_key='storage_backends') | ||
|
||
@mock.patch.object(endpoint_storage.EndpointStorageManager, '_get') | ||
def test_get_default( | ||
self, | ||
mock_get | ||
): | ||
mock_endpoint = mock.Mock() | ||
mock_endpoint.uuid = '53773ab8-1474-4cf7-bf0c-a496a6595ecb' | ||
mock_get.return_value = {"config_default": "mock_default"} | ||
|
||
result = self.endpoint.get_default( | ||
mock_endpoint, | ||
{"env": "mock_env"}, | ||
) | ||
|
||
self.assertEqual( | ||
"mock_default", | ||
result | ||
) | ||
mock_get.assert_called_once_with( | ||
('/endpoints/53773ab8-1474-4cf7-bf0c-a496a6595ecb/storage' | ||
'?env=eyJlbnYiOiAibW9ja19lbnYifQ=='), | ||
'storage') |