Skip to content

Commit

Permalink
Wrapper.get_task_histories_or_none を追加 (#367)
Browse files Browse the repository at this point in the history
* private ->protected

* update test

* version up

* updat

* update travis
  • Loading branch information
yuji38kwmt committed Oct 26, 2021
1 parent 6473419 commit 83ddadd
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ branches:
only:
- master
env:
# `poetry install`時に`Max retries exceeded with`が発生しないようにするため、タイムアウト時間を指定する
- PIP_DEFAULT_TIMEOUT=100

cache: pip


2 changes: 1 addition & 1 deletion annofabapi/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.48.2"
__version__ = "0.48.3"
19 changes: 17 additions & 2 deletions annofabapi/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def __to_dest_annotation_detail(

return dest_detail

def __create_request_body_for_copy_annotation(
def _create_request_body_for_copy_annotation(
self,
project_id: str,
task_id: str,
Expand Down Expand Up @@ -430,7 +430,7 @@ def copy_annotation(
old_dest_annotation, _ = self.api.get_editor_annotation(dest.project_id, dest.task_id, dest.input_data_id)
updated_datetime = old_dest_annotation["updated_datetime"]

request_body = self.__create_request_body_for_copy_annotation(
request_body = self._create_request_body_for_copy_annotation(
dest.project_id,
dest.task_id,
dest.input_data_id,
Expand Down Expand Up @@ -1478,6 +1478,21 @@ def get_task_or_none(self, project_id: str, task_id: str) -> Optional[Task]:
content, _ = self.api.get_task(project_id, task_id)
return content

@allow_404_error
def get_task_histories_or_none(self, project_id: str, task_id: str) -> Optional[Task]:
"""
タスク履歴一覧を取得する。存在しない場合(HTTP 404 Error)はNoneを返す。
Args:
project_id:
task_id:
Returns:
タスク履歴一覧
"""
content, _ = self.api.get_task_histories(project_id, task_id)
return content

def get_all_tasks(self, project_id: str, query_params: Optional[Dict[str, Any]] = None) -> List[Task]:
"""
すべてのタスクを取得する。
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "annofabapi"
version = "0.48.2"
version = "0.48.3"
description = "Python Clinet Library of AnnoFab WebAPI (https://annofab.com/docs/api/)"
authors = ["yuji38kwmt"]
license = "MIT"
Expand Down
7 changes: 7 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,13 @@ def test_get_task_or_none(self):

assert wrapper.get_task_or_none("not-exists", task_id) is None

def test_get_task_histories_or_none(self):
assert type(wrapper.get_task_histories_or_none(project_id, task_id)) == list

assert wrapper.get_task_histories_or_none(project_id, "not-exists") is None

assert wrapper.get_task_histories_or_none("not-exists", task_id) is None


class TestProtectedMethod:
@classmethod
Expand Down

0 comments on commit 83ddadd

Please sign in to comment.