Skip to content

Commit

Permalink
Merge pull request #74 from themotleyfool/add-update-category
Browse files Browse the repository at this point in the history
Add client endpoint for updating category
  • Loading branch information
bennylope committed Mar 1, 2023
2 parents 7898ff3 + e974827 commit 50465b4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/pydiscourse/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,18 @@ def category(self, category_id, parent=None, **kwargs):

return self._get(u"/c/{0}/show.json".format(category_id), **kwargs)

def update_category(self, category_id, **kwargs):
"""
Args:
category_id:
**kwargs:
Returns:
"""
return self._put("/categories/{0}".format(category_id), json=True, **kwargs)

def delete_category(self, category_id, **kwargs):
"""
Remove category
Expand Down
5 changes: 5 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ def test_categories(self, request):
self.assertRequestCalled(request, "GET", "/categories.json")
self.assertEqual(r, request().json()["category_list"]["categories"])

def test_update_category(self, request):
prepare_response(request)
self.client.update_category(123, a="a", b="b")
self.assertRequestCalled(request, "PUT", "/categories/123", a="a", b="b")

def test_users(self, request):
prepare_response(request)
self.client.users()
Expand Down

0 comments on commit 50465b4

Please sign in to comment.