Skip to content

Commit

Permalink
Add unit tests for coriolisclient.client.py module
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristi1324 committed Jun 7, 2024
1 parent aa80769 commit 1ee2305
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions coriolisclient/tests/test_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2024 Cloudbase Solutions Srl
# All Rights Reserved.

from unittest import mock

from coriolisclient import client as coriolis_client
from coriolisclient.tests import test_base


class _HTTPClientTestCase(test_base.CoriolisBaseTestCase):
"""Test suite for the Coriolis HTTP Client."""

def test__init__(self):
session = mock.Mock()
self.client = coriolis_client._HTTPClient(
session, endpoint=mock.sentinel.endpoint, version='v0')
self.assertEqual(
"%s/%s" % (mock.sentinel.endpoint, 'v0'),
self.client.endpoint_override
)

def test__init__no_endpoint(self):
session = mock.Mock()
self.client = coriolis_client._HTTPClient(session)
self.assertEqual(
None,
self.client.endpoint_override
)


class ClientTestCase(test_base.CoriolisBaseTestCase):
"""Test suite for the Coriolis Client."""

@mock.patch.object(coriolis_client, "_HTTPClient")
def test__init__(self, mock_HTTPClient):
try:
self.client = coriolis_client.Client(session=mock.sentinel.session)
except Exception:
self.fail("Failed to initialize Client")
mock_HTTPClient.assert_called_once_with(session=mock.sentinel.session)

0 comments on commit 1ee2305

Please sign in to comment.