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")