diff --git a/changes/100.feature b/changes/100.feature new file mode 100644 index 0000000..37b00e4 --- /dev/null +++ b/changes/100.feature @@ -0,0 +1 @@ +Add list_attachments on WikiPage diff --git a/taiga/models/models.py b/taiga/models/models.py index eb711c3..1c23503 100644 --- a/taiga/models/models.py +++ b/taiga/models/models.py @@ -1758,6 +1758,12 @@ def attach(self, attached_file, **attrs): """ return WikiAttachments(self.requester).create(self.project, self.id, attached_file, **attrs) + def list_attachments(self): + """ + Get a list of :class:`WikiAttachment`. + """ + return WikiAttachments(self.requester).list(object_id=self.id, project=self.project) + class WikiPages(ListResource): """ diff --git a/tests/test_wikipages.py b/tests/test_wikipages.py index 1a19aa6..6f4c786 100644 --- a/tests/test_wikipages.py +++ b/tests/test_wikipages.py @@ -5,6 +5,8 @@ from taiga.models import WikiPage, WikiPages from taiga.requestmaker import RequestMaker +from .tools import MockResponse, create_mock_json + import_open = "builtins.open" @@ -57,3 +59,14 @@ def test_not_valid_type_file_attach(self): rm = RequestMaker("/api/v1", "fakehost", "faketoken") wikipage = WikiPage(rm, id=1, project=1) self.assertRaises(TaigaException, wikipage.attach, 4) + + @patch("taiga.requestmaker.RequestMaker.get") + def test_list_attachments(self, mock_requestmaker_get): + mock_requestmaker_get.return_value = MockResponse( + 200, create_mock_json("tests/resources/issues_list_success.json") + ) + rm = RequestMaker("/api/v1", "fakehost", "faketoken") + WikiPage(rm, id=1, project=1).list_attachments() + mock_requestmaker_get.assert_called_with( + "wiki/attachments", query={"object_id": 1, "project": 1}, paginate=True + )