Skip to content

Commit

Permalink
Add tests for coriolis.api.v1.provider_schemas module
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristi1324 committed Dec 7, 2023
1 parent 9ba23f1 commit d6d4185
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions coriolis/tests/api/v1/test_provider_schemas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2023 Cloudbase Solutions Srl
# All Rights Reserved.

from unittest import mock

from coriolis.api.v1 import provider_schemas
from coriolis.providers import api
from coriolis.tests import test_base


class ProviderSchemasControllerTestCase(test_base.CoriolisBaseTestCase):
"""Test suite for the Coriolis Provider Schemas v1 API"""

def setUp(self):
super(ProviderSchemasControllerTestCase, self).setUp()
self.provider_schemas = provider_schemas.ProviderSchemasController()

@mock.patch.object(api.API, 'get_provider_schemas')
def test_index(
self,
get_provider_schemas
):
mock_req = mock.Mock()
mock_context = mock.Mock()
mock_req.environ = {'coriolis.context': mock_context}
mock_platform_name = "mock_platform_name"
mock_provider_type = "mock_provider_type"
expected_result = {
'schemas': get_provider_schemas.return_value
}

result = self.provider_schemas.index(
mock_req, mock_platform_name, mock_provider_type)

self.assertEqual(
expected_result,
result
)

get_provider_schemas.assert_called_once_with(
mock_context, mock_platform_name, mock_provider_type)

0 comments on commit d6d4185

Please sign in to comment.