Skip to content

Commit

Permalink
Add count to SearchResult object, fix wikipages attribute name in Sea…
Browse files Browse the repository at this point in the history
…rchResult object (#136)
  • Loading branch information
protoroto authored Aug 22, 2023
1 parent d601469 commit 6b562e9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions changes/111.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add count to SearchResult object, fix wikipages attribute name in SearchResult object
4 changes: 3 additions & 1 deletion taiga/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class SearchResult:
tasks = []
issues = []
user_stories = []
wiki_pages = []
wikipages = []
epics = []


class TaigaAPI:
Expand Down Expand Up @@ -114,6 +115,7 @@ def search(self, project, text=""):
result = self.raw_request.get("search", query={"project": project, "text": text})
result = result.json()
search_result = SearchResult()
search_result.count = result["count"]
search_result.tasks = self.tasks.parse_list(result["tasks"])
search_result.issues = self.issues.parse_list(result["issues"])
search_result.user_stories = self.user_stories.parse_list(result["userstories"])
Expand Down
2 changes: 2 additions & 0 deletions tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ def test_single_user_parsing(self, mock_requestmaker_get):
mock_requestmaker_get.return_value = MockResponse(200, create_mock_json("tests/resources/search_success.json"))
api = TaigaAPI(token="f4k3")
search_result = api.search(1, "NEW")
self.assertEqual(search_result.count, 3)
self.assertEqual(len(search_result.tasks), 1)
self.assertEqual(len(search_result.user_stories), 1)
self.assertEqual(len(search_result.issues), 1)
self.assertEqual(len(search_result.wikipages), 1)
self.assertEqual(len(search_result.epics), 2)

self.assertTrue(isinstance(search_result.count, int))
self.assertTrue(isinstance(search_result.tasks[0], Task))
self.assertTrue(isinstance(search_result.issues[0], Issue))
self.assertTrue(isinstance(search_result.user_stories[0], UserStory))
Expand Down

0 comments on commit 6b562e9

Please sign in to comment.