Skip to content

Commit

Permalink
Add tests for coriolis.api.v1.providers module
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristi1324 committed Dec 7, 2023
1 parent d6d4185 commit 6856898
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions coriolis/tests/api/v1/test_providers.py
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)

0 comments on commit 6856898

Please sign in to comment.