Skip to content

Commit

Permalink
Add list_attachments on WikiPage
Browse files Browse the repository at this point in the history
  • Loading branch information
protoroto committed Aug 22, 2023
1 parent d601469 commit 19f2faa
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions changes/100.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add list_attachments on WikiPage
6 changes: 6 additions & 0 deletions taiga/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
13 changes: 13 additions & 0 deletions tests/test_wikipages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand Down Expand Up @@ -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
)

0 comments on commit 19f2faa

Please sign in to comment.