Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add list_attachments on WikiPage #137

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
)
Loading