-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for
coriolisclient.client.py
module
- Loading branch information
1 parent
c9d9eac
commit 1d9cc4f
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |