Browse Source
Merge pull request #166 from Gromil/master
Added destructor to close requests.Session
pull/173/head
Marcos Pereira
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
36 additions and
31 deletions
-
keycloak/connection.py
-
keycloak/tests/test_connection.py
|
@ -60,6 +60,9 @@ class ConnectionManager(object): |
|
|
|
|
|
|
|
|
self._s.mount(protocol, adapter) |
|
|
self._s.mount(protocol, adapter) |
|
|
|
|
|
|
|
|
|
|
|
def __del__(self): |
|
|
|
|
|
self._s.close() |
|
|
|
|
|
|
|
|
@property |
|
|
@property |
|
|
def base_url(self): |
|
|
def base_url(self): |
|
|
""" Return base url in use for requests to the server. """ |
|
|
""" Return base url in use for requests to the server. """ |
|
|
|
@ -156,6 +156,7 @@ class TestConnection(unittest.TestCase): |
|
|
with mock.patch.object(KeycloakOpenID, "__init__", return_value=None) as mock_keycloak_open_id: |
|
|
with mock.patch.object(KeycloakOpenID, "__init__", return_value=None) as mock_keycloak_open_id: |
|
|
with mock.patch("keycloak.keycloak_openid.KeycloakOpenID.token", return_value=fake_token): |
|
|
with mock.patch("keycloak.keycloak_openid.KeycloakOpenID.token", return_value=fake_token): |
|
|
with mock.patch("keycloak.connection.ConnectionManager.__init__", return_value=None) as mock_connection_manager: |
|
|
with mock.patch("keycloak.connection.ConnectionManager.__init__", return_value=None) as mock_connection_manager: |
|
|
|
|
|
with mock.patch("keycloak.connection.ConnectionManager.__del__", return_value=None) as mock_connection_manager_delete: |
|
|
server_url = "https://localhost/auth/" |
|
|
server_url = "https://localhost/auth/" |
|
|
username = "admin" |
|
|
username = "admin" |
|
|
password = "secret" |
|
|
password = "secret" |
|
@ -187,3 +188,4 @@ class TestConnection(unittest.TestCase): |
|
|
headers=expected_header, |
|
|
headers=expected_header, |
|
|
timeout=60, |
|
|
timeout=60, |
|
|
verify=False) |
|
|
verify=False) |
|
|
|
|
|
mock_connection_manager_delete.assert_called_once_with() |