From e645e03a4fc5927be8ffa707f90e32374d124fc9 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Thu, 25 Jul 2024 14:03:41 -0400 Subject: [PATCH] Remove unused `_from_string` methods from SDK These were added in without a specific rationale but aren't used. If they are ever needed, we can re-add them or make the caller turn them into the correct object ahead of time. --- client/securedrop_client/sdk/__init__.py | 49 - .../data/test_delete_source_from_string.yml | 886 ------------------ .../test_delete_submission_from_string.yml | 484 ---------- .../test_get_single_source_from_string.yml | 683 -------------- .../data/test_get_submission_from_string.yml | 440 --------- client/tests/sdk/test_api.py | 16 - client/tests/sdk/test_shared.py | 29 +- 7 files changed, 8 insertions(+), 2579 deletions(-) delete mode 100644 client/tests/sdk/data/test_delete_source_from_string.yml delete mode 100644 client/tests/sdk/data/test_delete_submission_from_string.yml delete mode 100644 client/tests/sdk/data/test_get_single_source_from_string.yml delete mode 100644 client/tests/sdk/data/test_get_submission_from_string.yml diff --git a/client/securedrop_client/sdk/__init__.py b/client/securedrop_client/sdk/__init__.py index 7e2601f5f..3f70dac15 100644 --- a/client/securedrop_client/sdk/__init__.py +++ b/client/securedrop_client/sdk/__init__.py @@ -438,17 +438,6 @@ def get_source(self, source: Source) -> Source: return Source(**response.data) - def get_source_from_string(self, uuid: str) -> Source: - """ - This will fetch a source from server and return it. - - :param uuid: Source UUID as string. - :returns: Source object fetched from server for the given UUID value. - """ - - s = Source(uuid=uuid) - return self.get_source(s) - def delete_source(self, source: Source) -> bool: """ This method will delete the source and collection. If the UUID @@ -506,18 +495,6 @@ def delete_conversation(self, uuid: str) -> bool: return False - def delete_source_from_string(self, uuid: str) -> bool: - """ - This method will delete the source and collection. If the UUID - is not found in the server, it will raise WrongUUIDError. - - :param uuid: Source UUID as string. - :returns: True if the operation is successful. - """ - - s = Source(uuid=uuid) - return self.delete_source(s) - def add_star(self, source: Source) -> bool: """ Adds a star to a given source. @@ -626,18 +603,6 @@ def get_submission(self, submission: Submission) -> Submission: # XXX: is this the correct behavior return submission - def get_submission_from_string(self, uuid: str, source_uuid: str) -> Submission: - """ - Returns the updated Submission object from the server. - - :param uuid: UUID of the Submission object. - :param source_uuid: UUID of the source. - :returns: Updated submission object from the server. - """ - s = Submission(uuid=uuid) - s.source_uuid = source_uuid - return self.get_submission(s) - def get_all_submissions(self) -> list[Submission]: """ Returns a list of Submission objects from the server. @@ -673,7 +638,6 @@ def delete_submission(self, submission: Submission) -> bool: """ # Not using direct URL because this helps to use the same method # from local submission (not fetched from server) objects. - # See the *from_string for an example. path_query = f"api/v1/sources/{submission.source_uuid}/submissions/{submission.uuid}" method = "DELETE" @@ -693,18 +657,6 @@ def delete_submission(self, submission: Submission) -> bool: # We should never reach here return False - def delete_submission_from_string(self, uuid: str, source_uuid: str) -> bool: - """ - Deletes a given Submission based on UUIDs from the server. - - :param uuid: UUID of the Submission object. - :param source_uuid: UUID of the source. - :returns: Updated submission object from the server. - """ - s = Submission(uuid=uuid) - s.source_url = f"/api/v1/sources/{source_uuid}" - return self.delete_submission(s) - def download_submission( self, submission: Submission, path: str | None = None, timeout: int | None = None ) -> tuple[str, str]: @@ -982,7 +934,6 @@ def delete_reply(self, reply: Reply) -> bool: """ # Not using direct URL because this helps to use the same method # from local reply (not fetched from server) objects. - # See the *from_string for an example. path_query = f"api/v1/sources/{reply.source_uuid}/replies/{reply.uuid}" method = "DELETE" diff --git a/client/tests/sdk/data/test_delete_source_from_string.yml b/client/tests/sdk/data/test_delete_source_from_string.yml deleted file mode 100644 index 133638fe7..000000000 --- a/client/tests/sdk/data/test_delete_source_from_string.yml +++ /dev/null @@ -1,886 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/json - Authorization: - - Token Ilhha2ZHZWpVcFZQVmpKdWJOUzJYRG1YVUc4QXZWS0JiOGVNQXJycE5GUFUi.ZeDzXQ.10ODTj49yF7kxKbeMm9eaayR3Xo - Content-Type: - - application/json - method: GET - uri: api/v1/sources - response: !!python/object:securedrop_client.sdk.JSONResponse - data: - sources: - - add_star_url: /api/v1/sources/74241930-15f1-4eaf-9425-eb4e73c57a58/add_star - interaction_count: 6 - is_flagged: false - is_starred: false - journalist_designation: blue-eyed parallelogram - key: - fingerprint: 424CD740556BB98BDE82A2A2EC365C01C4524636 - public: '-----BEGIN PGP PUBLIC KEY BLOCK----- - - Comment: 424C D740 556B B98B DE82 A2A2 EC36 5C01 C452 4636 - - Comment: Source Key