From 2935cc25edd9fbeccda9da9b34d8e178aa7e4c73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samu=C3=ABl=20WEBER?= Date: Mon, 19 Feb 2024 16:20:53 +0100 Subject: [PATCH] add anonymize endpoint --- src/pydiscourse/client.py | 11 +++++++++++ tests/test_client.py | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/src/pydiscourse/client.py b/src/pydiscourse/client.py index 466fb51..6445172 100644 --- a/src/pydiscourse/client.py +++ b/src/pydiscourse/client.py @@ -230,6 +230,17 @@ def trust_level(self, userid, level): """ return self._put(f"/admin/users/{userid}/trust_level", level=level) + def anonymize(self, userid): + """ + + Args: + userid: the Discourse user ID + + Returns: + + """ + return self._put(f"/admin/users/{userid}/anonymize") + def suspend(self, userid, duration, reason): """ Suspend a user's account diff --git a/tests/test_client.py b/tests/test_client.py index 2848c16..f6395ba 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -83,6 +83,12 @@ def test_by_external_id(self, discourse_client, discourse_request): assert request.called_once + def test_anonymize(self, discourse_client, discourse_request): + request = discourse_request("put", "/admin/users/123/anonymize") + discourse_client.anonymize(123) + + assert request.called_once + @pytest.mark.usefixtures("_frozen_time") def test_suspend_user(self, discourse_client, discourse_request): request = discourse_request("put", "/admin/users/123/suspend")