-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for
coriolis.api.v1.providers
module
- Loading branch information
1 parent
d6d4185
commit 6856898
Showing
1 changed file
with
37 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,37 @@ | ||
# Copyright 2023 Cloudbase Solutions Srl | ||
# All Rights Reserved. | ||
|
||
from unittest import mock | ||
|
||
from coriolis.api.v1 import providers | ||
from coriolis.providers import api | ||
from coriolis.tests import test_base | ||
|
||
|
||
class ProviderControllerTestCase(test_base.CoriolisBaseTestCase): | ||
"""Test suite for the Coriolis Providers v1 API""" | ||
|
||
def setUp(self): | ||
super(ProviderControllerTestCase, self).setUp() | ||
self.providers = providers.ProviderController() | ||
|
||
@mock.patch.object(api.API, 'get_available_providers') | ||
def test_index( | ||
self, | ||
mock_get_available_providers | ||
): | ||
mock_req = mock.Mock() | ||
mock_context = mock.Mock() | ||
mock_req.environ = {'coriolis.context': mock_context} | ||
expected_result = { | ||
'providers': mock_get_available_providers.return_value | ||
} | ||
|
||
result = self.providers.index(mock_req) | ||
|
||
self.assertEqual( | ||
expected_result, | ||
result | ||
) | ||
|
||
mock_get_available_providers.assert_called_once_with(mock_context) |