From b14cf983a95d0dc834bdedd31b04f40729a880aa Mon Sep 17 00:00:00 2001 From: Cristian Matiut Date: Wed, 29 May 2024 15:03:58 +0300 Subject: [PATCH] Add unit tests for `coriolisclient.v1.licensing_server.py` module --- .../tests/v1/test_licensing_server.py | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 coriolisclient/tests/v1/test_licensing_server.py diff --git a/coriolisclient/tests/v1/test_licensing_server.py b/coriolisclient/tests/v1/test_licensing_server.py new file mode 100644 index 0000000..721f49f --- /dev/null +++ b/coriolisclient/tests/v1/test_licensing_server.py @@ -0,0 +1,39 @@ +# Copyright 2024 Cloudbase Solutions Srl +# All Rights Reserved. + +from unittest import mock + +from coriolisclient.tests import test_base +from coriolisclient.v1 import licensing +from coriolisclient.v1 import licensing_server + + +class LicensingServerManagerTestCase( + test_base.CoriolisBaseTestCase): + """Test suite for the Coriolis v1 Licensing Server Manager.""" + + @mock.patch.object(licensing, 'LicensingClient') + def setUp(self, mock_LicensingClient): + mock_client = mock.Mock() + self.mock_licencing_client = mock.Mock() + mock_LicensingClient.return_value = self.mock_licencing_client + super(LicensingServerManagerTestCase, self).setUp() + self.licence = licensing_server.LicensingServerManager( + mock_client) + + def test_status(self): + mock_resource_class = mock.Mock() + self.licence.resource_class = mock_resource_class + + result = self.licence.status() + + self.assertEqual( + mock_resource_class.return_value, + result + ) + self.mock_licencing_client.get.assert_called_once_with( + '/status', + response_key='status') + mock_resource_class.assert_called_once_with( + self.licence, self.mock_licencing_client.get.return_value, + loaded=True)