Skip to content

Commit bae72f9

Browse files
committed
: add task comments tests; docs: add API links to new methods
1 parent 69b3ac1 commit bae72f9

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed

crowdin_api/api_resources/tasks/resource.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,9 @@ def list_task_comments(
958958
):
959959
"""
960960
List Task Comments.
961+
962+
Link to documentation:
963+
https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.comments.getMany
961964
"""
962965

963966
projectId = projectId or self.get_project_id()
@@ -978,6 +981,9 @@ def add_task_comment(
978981
):
979982
"""
980983
Add Task Comment.
984+
985+
Link to documentation:
986+
https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.comments.post
981987
"""
982988

983989
projectId = projectId or self.get_project_id()
@@ -996,6 +1002,9 @@ def get_task_comment(
9961002
):
9971003
"""
9981004
Get Task Comment.
1005+
1006+
Link to documentation:
1007+
https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.comments.get
9991008
"""
10001009

10011010
projectId = projectId or self.get_project_id()
@@ -1015,6 +1024,9 @@ def delete_task_comment(
10151024
):
10161025
"""
10171026
Delete Task Comment.
1027+
1028+
Link to documentation:
1029+
https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.comments.delete
10181030
"""
10191031

10201032
projectId = projectId or self.get_project_id()
@@ -1035,6 +1047,9 @@ def edit_task_comment(
10351047
):
10361048
"""
10371049
Edit Task Comment.
1050+
1051+
Link to documentation:
1052+
https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.comments.patch
10381053
"""
10391054

10401055
projectId = projectId or self.get_project_id()

crowdin_api/api_resources/tasks/tests/test_tasks_resources.py

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,97 @@ def test_edit_task_archived_status(self, m_request, base_absolut_url):
13271327
request_data=[{"op": "replace", "path": "/isArchived", "value": False}],
13281328
)
13291329

1330+
# --- Task comments ---
1331+
@pytest.mark.parametrize(
1332+
"incoming_data, path",
1333+
(
1334+
({"projectId": 1, "taskId": 2}, "projects/1/tasks/2/comments"),
1335+
(
1336+
{"projectId": 1, "taskId": 2, "taskCommentId": 3},
1337+
"projects/1/tasks/2/comments/3",
1338+
),
1339+
),
1340+
)
1341+
def test_get_task_comments_path(self, incoming_data, path, base_absolut_url):
1342+
resource = self.get_resource(base_absolut_url)
1343+
assert resource.get_task_comments_path(**incoming_data) == path
1344+
1345+
@pytest.mark.parametrize(
1346+
"incoming_data, request_params",
1347+
(
1348+
({}, {"orderBy": None, "offset": 0, "limit": 25}),
1349+
({"orderBy": Sorting([])}, {"orderBy": Sorting([]), "offset": 0, "limit": 25}),
1350+
),
1351+
)
1352+
@mock.patch("crowdin_api.requester.APIRequester.request")
1353+
def test_list_task_comments(self, m_request, incoming_data, request_params, base_absolut_url):
1354+
m_request.return_value = "response"
1355+
1356+
resource = self.get_resource(base_absolut_url)
1357+
assert resource.list_task_comments(projectId=1, taskId=2, **incoming_data) == "response"
1358+
m_request.assert_called_once_with(
1359+
method="get",
1360+
params=request_params,
1361+
path=resource.get_task_comments_path(projectId=1, taskId=2),
1362+
)
1363+
1364+
@mock.patch("crowdin_api.requester.APIRequester.request")
1365+
def test_add_task_comment(self, m_request, base_absolut_url):
1366+
m_request.return_value = "response"
1367+
1368+
resource = self.get_resource(base_absolut_url)
1369+
assert resource.add_task_comment(projectId=1, taskId=2, text="hello") == "response"
1370+
m_request.assert_called_once_with(
1371+
method="post",
1372+
path=resource.get_task_comments_path(projectId=1, taskId=2),
1373+
request_data={"text": "hello"},
1374+
)
1375+
1376+
@mock.patch("crowdin_api.requester.APIRequester.request")
1377+
def test_get_task_comment(self, m_request, base_absolut_url):
1378+
m_request.return_value = "response"
1379+
1380+
resource = self.get_resource(base_absolut_url)
1381+
assert resource.get_task_comment(projectId=1, taskId=2, taskCommentId=3) == "response"
1382+
m_request.assert_called_once_with(
1383+
method="get",
1384+
path=resource.get_task_comments_path(projectId=1, taskId=2, taskCommentId=3),
1385+
)
1386+
1387+
@mock.patch("crowdin_api.requester.APIRequester.request")
1388+
def test_delete_task_comment(self, m_request, base_absolut_url):
1389+
m_request.return_value = "response"
1390+
1391+
resource = self.get_resource(base_absolut_url)
1392+
assert resource.delete_task_comment(projectId=1, taskId=2, taskCommentId=3) == "response"
1393+
m_request.assert_called_once_with(
1394+
method="delete",
1395+
path=resource.get_task_comments_path(projectId=1, taskId=2, taskCommentId=3),
1396+
)
1397+
1398+
@mock.patch("crowdin_api.requester.APIRequester.request")
1399+
def test_edit_task_comment(self, m_request, base_absolut_url):
1400+
m_request.return_value = "response"
1401+
1402+
data = [
1403+
{
1404+
"value": "new text",
1405+
"op": PatchOperation.REPLACE,
1406+
"path": "/text",
1407+
}
1408+
]
1409+
1410+
resource = self.get_resource(base_absolut_url)
1411+
assert (
1412+
resource.edit_task_comment(projectId=1, taskId=2, taskCommentId=3, data=data)
1413+
== "response"
1414+
)
1415+
m_request.assert_called_once_with(
1416+
method="patch",
1417+
path=resource.get_task_comments_path(projectId=1, taskId=2, taskCommentId=3),
1418+
request_data=data,
1419+
)
1420+
13301421

13311422
class TestEnterpriseTasksResource:
13321423
resource_class = EnterpriseTasksResource

0 commit comments

Comments
 (0)