Skip to content

Commit

Permalink
get_supplementary_data_list_or_none を追加 (#392)
Browse files Browse the repository at this point in the history
* version up

* 補助情報の情報を追加

* update

* update

* version up

* 型ヒントを修正

* version up
  • Loading branch information
yuji38kwmt committed Jan 4, 2022
1 parent 1d70754 commit c1a81ec
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
2 changes: 1 addition & 1 deletion annofabapi/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.52.0"
__version__ = "0.52.3"
24 changes: 23 additions & 1 deletion annofabapi/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,28 @@ def wrapper(*args, **kwargs):
#########################################
# Public Method : Supplementary
#########################################

def get_supplementary_data_list_or_none(
self, project_id: str, input_data_id: str
) -> Optional[List[Dict[str, Any]]]:
"""
補助情報一覧を取得する。存在しない場合(HTTP 404 Error)はNoneを返す。
Args:
project_id:
input_data_id:
Returns:
補助情報一覧
"""
content, response = self.api.get_supplementary_data_list(project_id, input_data_id, raise_for_status=False)
if response.status_code == requests.codes.not_found:
return None
else:
_log_error_response(logger, response)
_raise_for_status(response)
return content

def put_supplementary_data_from_file(
self,
project_id,
Expand Down Expand Up @@ -1829,7 +1851,7 @@ def get_task_or_none(self, project_id: str, task_id: str) -> Optional[Task]:
_raise_for_status(response)
return content

def get_task_histories_or_none(self, project_id: str, task_id: str) -> Optional[Task]:
def get_task_histories_or_none(self, project_id: str, task_id: str) -> Optional[List[Task]]:
"""
タスク履歴一覧を取得する。存在しない場合(HTTP 404 Error)はNoneを返す。
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "annofabapi"
version = "0.52.0"
version = "0.52.3"
description = "Python Clinet Library of AnnoFab WebAPI (https://annofab.com/docs/api/)"
authors = ["yuji38kwmt"]
license = "MIT"
Expand Down Expand Up @@ -41,7 +41,7 @@ more-itertools = "*"
# format library
isort = "*"
autoflake = "*"
black = {version = "^21.11b0", allow-prereleases = true}
black = {version = "^21.12b0", allow-prereleases = true}

# lint library
flake8 = "*"
Expand Down
7 changes: 6 additions & 1 deletion tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,13 +529,18 @@ def test_supplementary(self):
)
assert type(content) == dict

supplementary_data_list = api.get_supplementary_data_list(project_id, self.input_data_id)[0]
supplementary_data_list = wrapper.get_supplementary_data_list_or_none(project_id, self.input_data_id)
assert len([e for e in supplementary_data_list if e["supplementary_data_id"] == supplementary_data_id]) == 1

api.delete_supplementary_data(project_id, self.input_data_id, supplementary_data_id)
supplementary_data_list = api.get_supplementary_data_list(project_id, self.input_data_id)[0]
assert len([e for e in supplementary_data_list if e["supplementary_data_id"] == supplementary_data_id]) == 0

# def test_wrapper_get_supplementary_data_list_or_none(self):
# # 2021/01/04時点では、存在しないinput_data_idを指定すると404 Errorは発生しないので、このテストは実施しない
# supplementary_data_list = wrapper.get_supplementary_data_list_or_none(project_id, "not-exists")
# assert supplementary_data_list is None


class TestTask:
@classmethod
Expand Down

0 comments on commit c1a81ec

Please sign in to comment.