From e0e7734c6485f49dc84efb2a5ccd46f1c9591bc6 Mon Sep 17 00:00:00 2001 From: Taylor Hodge Date: Thu, 28 Jan 2021 17:05:44 -0500 Subject: [PATCH 1/2] add delete connections/:id --- tests/test_sso.py | 7 +++++++ workos/sso.py | 13 +++++++++++++ workos/utils/request.py | 1 + 3 files changed, 21 insertions(+) diff --git a/tests/test_sso.py b/tests/test_sso.py index 26b85cbf..45dba4e0 100644 --- a/tests/test_sso.py +++ b/tests/test_sso.py @@ -225,3 +225,10 @@ def test_list_connections(self, mock_connections, mock_request_method): response = self.sso.list_connections() assert response.status_code == 200 assert response.response_dict == mock_connections + + def test_delete_connection(self, mock_request_method): + mock_response = Response() + mock_response.status_code = 200 + mock_request_method("delete", mock_response, 200) + response = self.sso.delete_connection(connection="connection_id") + assert response.status_code == 200 diff --git a/workos/sso.py b/workos/sso.py index ea1b5fd8..787d3c06 100644 --- a/workos/sso.py +++ b/workos/sso.py @@ -10,6 +10,7 @@ from workos.utils.request import ( RequestHelper, RESPONSE_TYPE_CODE, + REQUEST_METHOD_DELETE, REQUEST_METHOD_GET, REQUEST_METHOD_POST, ) @@ -213,3 +214,15 @@ def list_connections( params=params, token=workos.api_key, ) + + def delete_connection(self, connection): + """Deletes a single Connection + + Args: + connection (str): Connection unique identifier + """ + return self.request_helper.request( + "connections/{connection}".format(connection=connection), + method=REQUEST_METHOD_DELETE, + token=workos.api_key, + ) \ No newline at end of file diff --git a/workos/utils/request.py b/workos/utils/request.py index bcdee88d..79e03c11 100644 --- a/workos/utils/request.py +++ b/workos/utils/request.py @@ -14,6 +14,7 @@ RESPONSE_TYPE_CODE = "code" +REQUEST_METHOD_DELETE = "delete" REQUEST_METHOD_GET = "get" REQUEST_METHOD_POST = "post" From ecdbe7f84ed9f57d7ca5dbfa5b7b507397534bed Mon Sep 17 00:00:00 2001 From: Taylor Hodge Date: Thu, 28 Jan 2021 17:07:17 -0500 Subject: [PATCH 2/2] format --- tests/test_sso.py | 2 +- workos/sso.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_sso.py b/tests/test_sso.py index 45dba4e0..40e3f0e5 100644 --- a/tests/test_sso.py +++ b/tests/test_sso.py @@ -225,7 +225,7 @@ def test_list_connections(self, mock_connections, mock_request_method): response = self.sso.list_connections() assert response.status_code == 200 assert response.response_dict == mock_connections - + def test_delete_connection(self, mock_request_method): mock_response = Response() mock_response.status_code = 200 diff --git a/workos/sso.py b/workos/sso.py index 787d3c06..047bf697 100644 --- a/workos/sso.py +++ b/workos/sso.py @@ -225,4 +225,4 @@ def delete_connection(self, connection): "connections/{connection}".format(connection=connection), method=REQUEST_METHOD_DELETE, token=workos.api_key, - ) \ No newline at end of file + )