Skip to content

Commit

Permalink
Add tests for coriolis.endpoint_resources.api module
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristi1324 authored and Dany9966 committed Apr 16, 2024
1 parent 4c40b7a commit d1fe20c
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
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
)

0 comments on commit d1fe20c

Please sign in to comment.