From 31a1d1cec4df7291abfac349e244ac46913eaa04 Mon Sep 17 00:00:00 2001 From: Peter Hamilton Date: Thu, 21 Sep 2017 12:57:44 -0400 Subject: [PATCH] Updating the ProxyKmipClient to simplify closing This change updates the ProxyKmipClient close method, allowing it to be called without error even when the client connection is not open. The client unit tests have been updated to reflect this. --- kmip/pie/client.py | 3 +-- kmip/tests/unit/pie/test_client.py | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/kmip/pie/client.py b/kmip/pie/client.py index 7a270a2..423cbea 100644 --- a/kmip/pie/client.py +++ b/kmip/pie/client.py @@ -134,11 +134,10 @@ class ProxyKmipClient(api.KmipClient): Close the client connection. Raises: - ClientConnectionNotOpen: if the client connection is not open Exception: if an error occurs while trying to close the connection """ if not self._is_open: - raise exceptions.ClientConnectionNotOpen() + return else: try: self.proxy.close() diff --git a/kmip/tests/unit/pie/test_client.py b/kmip/tests/unit/pie/test_client.py index c3cd087..92a572e 100644 --- a/kmip/tests/unit/pie/test_client.py +++ b/kmip/tests/unit/pie/test_client.py @@ -115,11 +115,10 @@ class TestProxyKmipClient(testtools.TestCase): mock.MagicMock(spec_set=KMIPProxy)) def test_close_on_close(self): """ - Test that a ClientConnectionNotOpen exception is raised when trying - to close a closed client connection. + Test that a closed client connection can be closed with no error. """ client = ProxyKmipClient() - self.assertRaises(ClientConnectionNotOpen, client.close) + client.close() @mock.patch('kmip.pie.client.KMIPProxy', mock.MagicMock(spec_set=KMIPProxy))