Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for coriolis.endpoint_resources.api module #303

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
93 changes: 93 additions & 0 deletions coriolis/tests/endpoint_resources/test_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Copyright 2024 Cloudbase Solutions Srl
# All Rights Reserved.

from unittest import mock

from coriolis.endpoint_resources import api
from coriolis.tests import test_base

ARGS = {
"ctxt": "mock_ctxt",
"endpoint_id": "mock_endpoint_id"
}


class EndpointResourcesAPITestCase(test_base.CoriolisBaseTestCase):
"""Test suite for the Coriolis Endpoint Resources API."""

def setUp(self):
super(EndpointResourcesAPITestCase, self).setUp()
self.endpoint_resources_api = api.API()
self.endpoint_resources_api._rpc_client = mock.Mock()

def test_get_endpoint_instances(self):
result = self.endpoint_resources_api.get_endpoint_instances(
**ARGS,
source_environment=mock.sentinel.source_environment,
marker=mock.sentinel.marker,
limit=mock.sentinel.limit,
instance_name_pattern=mock.sentinel.instance_name_pattern
)
(self.endpoint_resources_api._rpc_client.
get_endpoint_instances.assert_called_once_with)(
*(ARGS.values()),
mock.sentinel.source_environment,
mock.sentinel.marker,
mock.sentinel.limit,
mock.sentinel.instance_name_pattern
)
self.assertEqual(
(self.endpoint_resources_api._rpc_client.
get_endpoint_instances.return_value),
result
)

def test_get_endpoint_instance(self):
result = self.endpoint_resources_api.get_endpoint_instance(
**ARGS,
source_environment=mock.sentinel.source_environment,
instance_name=mock.sentinel.instance_name
)
(self.endpoint_resources_api._rpc_client.
get_endpoint_instance.assert_called_once_with)(
*(ARGS.values()),
mock.sentinel.source_environment,
mock.sentinel.instance_name
)
self.assertEqual(
(self.endpoint_resources_api._rpc_client.
get_endpoint_instance.return_value),
result
)

def test_get_endpoint_networks(self):
result = self.endpoint_resources_api.get_endpoint_networks(
**ARGS,
env=mock.sentinel.env
)
(self.endpoint_resources_api._rpc_client.
get_endpoint_networks.assert_called_once_with)(
*(ARGS.values()),
mock.sentinel.env
)
self.assertEqual(
(self.endpoint_resources_api._rpc_client.
get_endpoint_networks.return_value),
result
)

def test_get_endpoint_storage(self):
result = self.endpoint_resources_api.get_endpoint_storage(
**ARGS,
env=mock.sentinel.env
)
(self.endpoint_resources_api._rpc_client.
get_endpoint_storage.assert_called_once_with)(
*(ARGS.values()),
mock.sentinel.env
)
self.assertEqual(
(self.endpoint_resources_api._rpc_client.
get_endpoint_storage.return_value),
result
)
Loading