mirror of https://github.com/OpenKMIP/PyKMIP.git
Merge pull request #338 from OpenKMIP/feat/update-client-close
Updating the ProxyKmipClient to simplify closing
This commit is contained in:
commit
833b936603
|
@ -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()
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue