Skip to content
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
22 changes: 22 additions & 0 deletions crowdin_api/api_resources/string_comments/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def add_string_comment(
type: StringCommentType,
projectId: Optional[int] = None,
issueType: Optional[StringCommentIssueType] = None,
attachments: Optional[Iterable[int]] = None,
):
"""
Add String Comment.
Expand All @@ -88,6 +89,7 @@ def add_string_comment(
"targetLanguageId": targetLanguageId,
"type": type,
"issueType": issueType,
"attachments": attachments,
},
)

Expand Down Expand Up @@ -127,6 +129,26 @@ def delete_string_comment(
),
)

def delete_string_comment_attachment(
self, stringCommentId: int, attachmentId: int, projectId: Optional[int] = None
):
"""
Delete String Comment Attachment.

Link to documentation:
https://developer.crowdin.com/api/v2/#operation/api.projects.comments.attachments.delete
"""

projectId = projectId or self.get_project_id()

return self.requester.request(
method="delete",
path=(
f"{self.get_string_comments_path(projectId=projectId, stringCommentId=stringCommentId)}"
f"/attachments/{attachmentId}"
),
)

def edit_string_comment(
self,
stringCommentId: int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def test_list_string_comments(self, m_request, in_params, request_params, base_a
"targetLanguageId": "ua",
"type": StringCommentType.COMMENT,
"issueType": None,
"attachments": None,
},
),
(
Expand All @@ -119,13 +120,15 @@ def test_list_string_comments(self, m_request, in_params, request_params, base_a
"targetLanguageId": "ua",
"type": StringCommentType.COMMENT,
"issueType": StringCommentIssueType.CONTEXT_REQUEST,
"attachments": [1, 2, 3],
},
{
"text": "text",
"stringId": 1,
"targetLanguageId": "ua",
"type": StringCommentType.COMMENT,
"issueType": StringCommentIssueType.CONTEXT_REQUEST,
"attachments": [1, 2, 3],
},
),
),
Expand All @@ -142,6 +145,17 @@ def test_add_string_comment(self, m_request, in_params, request_data, base_absol
request_data=request_data,
)

@mock.patch("crowdin_api.requester.APIRequester.request")
def test_delete_string_comment_attachment(self, m_request, base_absolut_url):
m_request.return_value = "response"

resource = self.get_resource(base_absolut_url)
assert resource.delete_string_comment_attachment(projectId=1, stringCommentId=2, attachmentId=3) == "response"
m_request.assert_called_once_with(
method="delete",
path=resource.get_string_comments_path(projectId=1, stringCommentId=2) + "/attachments/3",
)

@mock.patch("crowdin_api.requester.APIRequester.request")
def test_get_string_comment(self, m_request, base_absolut_url):
m_request.return_value = "response"
Expand Down