diff --git a/crowdin_api/api_resources/tasks/enums.py b/crowdin_api/api_resources/tasks/enums.py index 5a52c8a..7b9070f 100644 --- a/crowdin_api/api_resources/tasks/enums.py +++ b/crowdin_api/api_resources/tasks/enums.py @@ -79,10 +79,6 @@ class OhtCrowdinTaskExpertise(Enum): # Gengo -class GengoCrowdinTaskType(Enum): - TRANSLATE_BY_VENDOR = 2 - - class GengoCrowdinTaskExpertise(Enum): STANDARD = "standard" PRO = "pro" @@ -109,10 +105,6 @@ class GengoCrowdinTaskPurpose(Enum): # Translated -class TranslatedCrowdinTaskType(Enum): - TRANSLATE_BY_VENDOR = 2 - - class TranslatedCrowdinTaskExpertise(Enum): ECONOMY = "P" PROFESSIONAL = "T" diff --git a/crowdin_api/api_resources/tasks/resource.py b/crowdin_api/api_resources/tasks/resource.py index b3dc0d4..677e437 100644 --- a/crowdin_api/api_resources/tasks/resource.py +++ b/crowdin_api/api_resources/tasks/resource.py @@ -5,21 +5,21 @@ from crowdin_api.api_resources.tasks.enums import ( CrowdinGeneralTaskType, CrowdinTaskStatus, + CrowdinTaskType, LanguageServiceTaskType, GengoCrowdinTaskExpertise, GengoCrowdinTaskPurpose, GengoCrowdinTaskTone, - GengoCrowdinTaskType, OhtCrowdinTaskExpertise, OhtCrowdinTaskType, TranslatedCrowdinTaskExpertise, TranslatedCrowdinTaskSubjects, - TranslatedCrowdinTaskType, ManualCrowdinTaskType, ManualCrowdinVendors, ) from crowdin_api.api_resources.tasks.types import ( CrowdinTaskAssignee, + EnterpriseTaskAssignedTeams, TaskPatchRequest, VendorPatchRequest, ConfigPatchRequest, @@ -225,9 +225,8 @@ def add_general_task( projectId: Optional[int] = None, status: Optional[CrowdinTaskStatus] = None, description: Optional[str] = None, - splitFiles: Optional[bool] = None, + splitContent: Optional[bool] = None, skipAssignedStrings: Optional[bool] = None, - skipUntranslatedStrings: Optional[bool] = None, includePreTranslatedStringsOnly: Optional[bool] = None, labelIds: Optional[Iterable[int]] = None, excludeLabelIds: Optional[Iterable[int]] = None, @@ -255,9 +254,8 @@ def add_general_task( "type": type, "status": status, "description": description, - "splitFiles": splitFiles, + "splitContent": splitContent, "skipAssignedStrings": skipAssignedStrings, - "skipUntranslatedStrings": skipUntranslatedStrings, "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, "labelIds": labelIds, "excludeLabelIds": excludeLabelIds, @@ -269,20 +267,65 @@ def add_general_task( }, ) + def add_general_by_string_ids_task( + self, + title: str, + languageId: str, + stringIds: Iterable[int], + type: CrowdinGeneralTaskType, + projectId: Optional[int] = None, + status: Optional[CrowdinTaskStatus] = None, + description: Optional[str] = None, + splitContent: Optional[bool] = None, + skipAssignedStrings: Optional[bool] = None, + includePreTranslatedStringsOnly: Optional[bool] = None, + assignees: Optional[Iterable[CrowdinTaskAssignee]] = None, + deadline: Optional[datetime] = None, + startedAt: Optional[datetime] = None, + dateFrom: Optional[datetime] = None, + dateTo: Optional[datetime] = None, + ): + """ + Add Task(Crowdin Task Create Form). + + Link to documentation: + https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.post + """ + + projectId = projectId or self.get_project_id() + + return self.add_task( + projectId=projectId, + request_data={ + "title": title, + "languageId": languageId, + "stringIds": stringIds, + "type": type, + "status": status, + "description": description, + "splitContent": splitContent, + "skipAssignedStrings": skipAssignedStrings, + "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, + "assignees": assignees, + "deadline": deadline, + "startedAt": startedAt, + "dateFrom": dateFrom, + "dateTo": dateTo, + }, + ) + def add_language_service_task( self, title: str, languageId: str, - fileIds: Iterable[str], + fileIds: Iterable[int], type: LanguageServiceTaskType, projectId: Optional[int] = None, status: Optional[CrowdinTaskStatus] = None, description: Optional[str] = None, labelIds: Optional[Iterable[int]] = None, excludeLabelIds: Optional[Iterable[int]] = None, - skipUntranslatedStrings: Optional[bool] = None, includePreTranslatedStringsOnly: Optional[bool] = None, - includeUntranslatedStringsOnly: Optional[bool] = None, dateFrom: Optional[datetime] = None, dateTo: Optional[datetime] = None, ): @@ -307,9 +350,45 @@ def add_language_service_task( "description": description, "labelIds": labelIds, "excludeLabelIds": excludeLabelIds, - "skipUntranslatedStrings": skipUntranslatedStrings, "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, - "includeUntranslatedStringsOnly": includeUntranslatedStringsOnly, + "dateFrom": dateFrom, + "dateTo": dateTo, + } + ) + + def add_language_service_by_string_ids_task( + self, + title: str, + languageId: str, + stringIds: Iterable[int], + type: LanguageServiceTaskType, + projectId: Optional[int] = None, + status: Optional[CrowdinTaskStatus] = None, + description: Optional[str] = None, + includePreTranslatedStringsOnly: Optional[bool] = None, + dateFrom: Optional[datetime] = None, + dateTo: Optional[datetime] = None, + ): + """ + Add Task(Crowdin Language Service Task Create Form). + + Link to documentation: + https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.post + """ + + projectId = projectId or self.get_project_id() + + return self.add_task( + projectId=projectId, + request_data={ + "title": title, + "languageId": languageId, + "stringIds": stringIds, + "type": type, + "vendor": "crowdin_language_service", + "status": status, + "description": description, + "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, "dateFrom": dateFrom, "dateTo": dateTo, } @@ -325,11 +404,10 @@ def add_vendor_oht_task( status: Optional[CrowdinTaskStatus] = None, description: Optional[str] = None, expertise: Optional[OhtCrowdinTaskExpertise] = None, + editService: Optional[bool] = None, labelIds: Optional[Iterable[int]] = None, excludeLabelIds: Optional[Iterable[int]] = None, - skipUntranslatedStrings: Optional[bool] = None, includePreTranslatedStringsOnly: Optional[bool] = None, - includeUntranslatedStringsOnly: Optional[bool] = None, dateFrom: Optional[datetime] = None, dateTo: Optional[datetime] = None, ): @@ -352,11 +430,52 @@ def add_vendor_oht_task( "status": status, "description": description, "expertise": expertise, + "editService": editService, "labelIds": labelIds, "excludeLabelIds": excludeLabelIds, - "skipUntranslatedStrings": skipUntranslatedStrings, "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, - "includeUntranslatedStringsOnly": includeUntranslatedStringsOnly, + "dateFrom": dateFrom, + "dateTo": dateTo, + "vendor": "oht", + }, + ) + + def add_vendor_oht_by_string_ids_task( + self, + title: str, + languageId: str, + stringIds: Iterable[int], + type: OhtCrowdinTaskType, + projectId: Optional[int] = None, + status: Optional[CrowdinTaskStatus] = None, + description: Optional[str] = None, + expertise: Optional[OhtCrowdinTaskExpertise] = None, + editService: Optional[bool] = None, + includePreTranslatedStringsOnly: Optional[bool] = None, + dateFrom: Optional[datetime] = None, + dateTo: Optional[datetime] = None, + ): + """ + Add Task(Crowdin Vendor Oht Task Create Form). + + Link to documentation: + https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.post + """ + + projectId = projectId or self.get_project_id() + + return self.add_task( + projectId=projectId, + request_data={ + "title": title, + "languageId": languageId, + "stringIds": stringIds, + "type": type, + "status": status, + "description": description, + "expertise": expertise, + "editService": editService, + "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, "dateFrom": dateFrom, "dateTo": dateTo, "vendor": "oht", @@ -368,7 +487,6 @@ def add_vendor_gengo_task( title: str, languageId: str, fileIds: Iterable[int], - type: GengoCrowdinTaskType, projectId: Optional[int] = None, status: Optional[CrowdinTaskStatus] = None, description: Optional[str] = None, @@ -398,7 +516,7 @@ def add_vendor_gengo_task( "title": title, "languageId": languageId, "fileIds": fileIds, - "type": type, + "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, "status": status, "description": description, "expertise": expertise, @@ -415,12 +533,58 @@ def add_vendor_gengo_task( }, ) + def add_vendor_gengo_by_string_ids_task( + self, + title: str, + languageId: str, + stringIds: Iterable[int], + projectId: Optional[int] = None, + status: Optional[CrowdinTaskStatus] = None, + description: Optional[str] = None, + expertise: Optional[GengoCrowdinTaskExpertise] = None, + tone: Optional[GengoCrowdinTaskTone] = None, + purpose: Optional[GengoCrowdinTaskPurpose] = None, + customerMessage: Optional[str] = None, + usePreferred: Optional[bool] = None, + editService: Optional[bool] = None, + dateFrom: Optional[datetime] = None, + dateTo: Optional[datetime] = None, + ): + """ + Add Task(Crowdin Vendor Gengo Task Create Form). + + Link to documentation: + https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.post + """ + + projectId = projectId or self.get_project_id() + + return self.add_task( + projectId=projectId, + request_data={ + "title": title, + "languageId": languageId, + "stringIds": stringIds, + "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, + "status": status, + "description": description, + "expertise": expertise, + "tone": tone, + "purpose": purpose, + "customerMessage": customerMessage, + "usePreferred": usePreferred, + "editService": editService, + "dateFrom": dateFrom, + "dateTo": dateTo, + "vendor": "gengo", + }, + ) + def add_vendor_translated_task( self, title: str, languageId: str, fileIds: Iterable[int], - type: TranslatedCrowdinTaskType, projectId: Optional[int] = None, status: Optional[CrowdinTaskStatus] = None, description: Optional[str] = None, @@ -446,7 +610,7 @@ def add_vendor_translated_task( "title": title, "languageId": languageId, "fileIds": fileIds, - "type": type, + "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, "status": status, "description": description, "expertise": expertise, @@ -455,7 +619,46 @@ def add_vendor_translated_task( "excludeLabelIds": excludeLabelIds, "dateFrom": dateFrom, "dateTo": dateTo, - "vender": "translated", + "vendor": "translated", + }, + ) + + def add_vendor_translated_by_string_ids_task( + self, + title: str, + languageId: str, + stringIds: Iterable[int], + projectId: Optional[int] = None, + status: Optional[CrowdinTaskStatus] = None, + description: Optional[str] = None, + expertise: Optional[TranslatedCrowdinTaskExpertise] = None, + subject: Optional[TranslatedCrowdinTaskSubjects] = None, + dateFrom: Optional[datetime] = None, + dateTo: Optional[datetime] = None, + ): + """ + Add Task(Crowdin Vendor Translated Task Create Form). + + Link to documentation: + https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.post + """ + + projectId = projectId or self.get_project_id() + + return self.add_task( + projectId=projectId, + request_data={ + "title": title, + "languageId": languageId, + "stringIds": stringIds, + "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, + "status": status, + "description": description, + "expertise": expertise, + "subject": subject, + "dateFrom": dateFrom, + "dateTo": dateTo, + "vendor": "translated", }, ) @@ -470,7 +673,6 @@ def add_vendor_manual_task( status: Optional[CrowdinTaskStatus] = None, description: Optional[str] = None, skipAssignedStrings: Optional[bool] = None, - skipUntranslatedStrings: Optional[bool] = None, includePreTranslatedStringsOnly: Optional[bool] = None, labelIds: Optional[Iterable[int]] = None, excludeLabelIds: Optional[Iterable[int]] = None, @@ -500,7 +702,6 @@ def add_vendor_manual_task( "status": status, "description": description, "skipAssignedStrings": skipAssignedStrings, - "skipUntranslatedStrings": skipUntranslatedStrings, "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, "labelIds": labelIds, "excludeLabelIds": excludeLabelIds, @@ -512,6 +713,135 @@ def add_vendor_manual_task( }, ) + def add_vendor_manual_by_string_ids_task( + self, + title: str, + languageId: str, + stringIds: Iterable[int], + type: ManualCrowdinTaskType, + vendor: ManualCrowdinVendors, + projectId: Optional[int] = None, + status: Optional[CrowdinTaskStatus] = None, + description: Optional[str] = None, + skipAssignedStrings: Optional[bool] = None, + includePreTranslatedStringsOnly: Optional[bool] = None, + assignees: Optional[Iterable[CrowdinTaskAssignee]] = None, + deadline: Optional[datetime] = None, + startedAt: Optional[datetime] = None, + dateFrom: Optional[datetime] = None, + dateTo: Optional[datetime] = None, + ): + """ + Add Task(Crowdin Vendor Manual Task Create Form). + + Link to documentation: + https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.post + """ + + projectId = projectId or self.get_project_id() + + return self.add_task( + projectId=projectId, + request_data={ + "title": title, + "languageId": languageId, + "stringIds": stringIds, + "type": type, + "vendor": vendor, + "status": status, + "description": description, + "skipAssignedStrings": skipAssignedStrings, + "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, + "assignees": assignees, + "deadline": deadline, + "startedAt": startedAt, + "dateFrom": dateFrom, + "dateTo": dateTo, + }, + ) + + def add_pending_task( + self, + title: str, + precedingTaskId: int, + projectId: Optional[int] = None, + description: Optional[str] = None, + assignees: Optional[Iterable[CrowdinTaskAssignee]] = None, + deadline: Optional[datetime] = None, + ): + """ + Add Task(Crowdin Pending Task Create Form). + """ + + projectId = projectId or self.get_project_id() + + return self.add_task( + projectId=projectId, + request_data={ + "precedingTaskId": precedingTaskId, + "type": CrowdinTaskType.PROOFREAD, + "title": title, + "description": description, + "assignees": assignees, + "deadline": deadline, + }, + ) + + def add_language_service_pending_task( + self, + title: str, + precedingTaskId: int, + projectId: Optional[int] = None, + description: Optional[str] = None, + deadline: Optional[datetime] = None, + ): + """ + Add Task(Crowdin Language Service Pending Task Create Form). + """ + + projectId = projectId or self.get_project_id() + + return self.add_task( + projectId=projectId, + request_data={ + "precedingTaskId": precedingTaskId, + "type": LanguageServiceTaskType.PROOFREAD_BY_VENDOR, + "vendor": "crowdin_language_service", + "title": title, + "description": description, + "deadline": deadline, + }, + ) + + def add_vendor_manual_pending_task( + self, + title: str, + precedingTaskId: int, + vendor: ManualCrowdinVendors, + projectId: Optional[int] = None, + description: Optional[str] = None, + assignees: Optional[Iterable[CrowdinTaskAssignee]] = None, + deadline: Optional[datetime] = None, + ): + """ + Add Task(Crowdin Vendor Manual Pending Task Create Form). + """ + + projectId = projectId or self.get_project_id() + + return self.add_task( + projectId=projectId, + request_data={ + "precedingTaskId": precedingTaskId, + "type": ManualCrowdinTaskType.PROOFREAD_BY_VENDOR, + "vendor": vendor, + "title": title, + "description": description, + "assignees": assignees, + "deadline": deadline, + }, + ) + def export_task_strings(self, taskId: int, projectId: Optional[int] = None): """ Export Task Strings. @@ -655,3 +985,223 @@ def add_task_settings_template( path=self.get_task_settings_templates_path(projectId=projectId), request_data={"name": name, "config": config}, ) + + def add_general_task( + self, + title: str, + languageId: str, + fileIds: Iterable[int], + type: CrowdinGeneralTaskType, + workflowStepId: Optional[int] = None, + projectId: Optional[int] = None, + status: Optional[CrowdinTaskStatus] = None, + description: Optional[str] = None, + splitContent: Optional[bool] = None, + skipAssignedStrings: Optional[bool] = None, + includePreTranslatedStringsOnly: Optional[bool] = None, + labelIds: Optional[Iterable[int]] = None, + excludeLabelIds: Optional[Iterable[int]] = None, + assignees: Optional[Iterable[CrowdinTaskAssignee]] = None, + assignedTeams: Optional[Iterable[EnterpriseTaskAssignedTeams]] = None, + deadline: Optional[datetime] = None, + startedAt: Optional[datetime] = None, + dateFrom: Optional[datetime] = None, + dateTo: Optional[datetime] = None, + ): + """ + Add Task(Enterprise Task Create Form). + + Link to documentation for enterprise: + https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.tasks.post + """ + + projectId = projectId or self.get_project_id() + + return self.add_task( + projectId=projectId, + request_data={ + "title": title, + "languageId": languageId, + "fileIds": fileIds, + "type": type, + "workflowStepId": workflowStepId, + "status": status, + "description": description, + "splitContent": splitContent, + "skipAssignedStrings": skipAssignedStrings, + "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, + "labelIds": labelIds, + "excludeLabelIds": excludeLabelIds, + "assignees": assignees, + "assignedTeams": assignedTeams, + "deadline": deadline, + "startedAt": startedAt, + "dateFrom": dateFrom, + "dateTo": dateTo, + }, + ) + + def add_general_by_string_ids_task( + self, + title: str, + languageId: str, + stringIds: Iterable[int], + type: Optional[CrowdinGeneralTaskType] = None, + workflowStepId: Optional[int] = None, + projectId: Optional[int] = None, + status: Optional[CrowdinTaskStatus] = None, + description: Optional[str] = None, + splitContent: Optional[bool] = None, + skipAssignedStrings: Optional[bool] = None, + includePreTranslatedStringsOnly: Optional[bool] = None, + assignees: Optional[Iterable[CrowdinTaskAssignee]] = None, + assignedTeams: Optional[Iterable[EnterpriseTaskAssignedTeams]] = None, + deadline: Optional[datetime] = None, + startedAt: Optional[datetime] = None, + dateFrom: Optional[datetime] = None, + dateTo: Optional[datetime] = None, + ): + """ + Add Task(Enterprise Task Create Form). + + Link to documentation for enterprise: + https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.tasks.post + """ + + projectId = projectId or self.get_project_id() + + return self.add_task( + projectId=projectId, + request_data={ + "title": title, + "languageId": languageId, + "stringIds": stringIds, + "type": type, + "workflowStepId": workflowStepId, + "status": status, + "description": description, + "splitContent": splitContent, + "skipAssignedStrings": skipAssignedStrings, + "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, + "assignees": assignees, + "assignedTeams": assignedTeams, + "deadline": deadline, + "startedAt": startedAt, + "dateFrom": dateFrom, + "dateTo": dateTo, + }, + ) + + def add_vendor_task( + self, + title: str, + languageId: str, + workflowStepId: int, + fileIds: Iterable[int], + projectId: Optional[int] = None, + description: Optional[str] = None, + skipAssignedStrings: Optional[bool] = None, + includePreTranslatedStringsOnly: Optional[bool] = None, + labelIds: Optional[Iterable[int]] = None, + excludeLabelIds: Optional[Iterable[int]] = None, + deadline: Optional[datetime] = None, + startedAt: Optional[datetime] = None, + dateTo: Optional[datetime] = None, + ): + """ + Add Task(Enterprise Vendor Task Create Form). + + Link to documentation for enterprise: + https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.tasks.post + """ + + projectId = projectId or self.get_project_id() + + return self.add_task( + projectId=projectId, + request_data={ + "title": title, + "languageId": languageId, + "fileIds": fileIds, + "workflowStepId": workflowStepId, + "description": description, + "skipAssignedStrings": skipAssignedStrings, + "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, + "labelIds": labelIds, + "excludeLabelIds": excludeLabelIds, + "deadline": deadline, + "startedAt": startedAt, + "dateTo": dateTo, + }, + ) + + def add_vendor_by_string_ids_task( + self, + title: str, + languageId: str, + workflowStepId: int, + stringIds: Iterable[int], + projectId: Optional[int] = None, + description: Optional[str] = None, + skipAssignedStrings: Optional[bool] = None, + includePreTranslatedStringsOnly: Optional[bool] = None, + deadline: Optional[datetime] = None, + startedAt: Optional[datetime] = None, + dateTo: Optional[datetime] = None, + ): + """ + Add Task(Enterprise Vendor Task Create Form). + + Link to documentation for enterprise: + https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.tasks.post + """ + + projectId = projectId or self.get_project_id() + + return self.add_task( + projectId=projectId, + request_data={ + "title": title, + "languageId": languageId, + "stringIds": stringIds, + "workflowStepId": workflowStepId, + "description": description, + "skipAssignedStrings": skipAssignedStrings, + "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, + "deadline": deadline, + "startedAt": startedAt, + "dateTo": dateTo, + }, + ) + + def add_pending_task( + self, + title: str, + precedingTaskId: int, + projectId: Optional[int] = None, + description: Optional[str] = None, + assignees: Optional[Iterable[CrowdinTaskAssignee]] = None, + assignedTeams: Optional[Iterable[EnterpriseTaskAssignedTeams]] = None, + deadline: Optional[datetime] = None, + ): + """ + Add Task(Enterprise Pending Task Create Form). + + Link to documentation for enterprise: + https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.tasks.post + """ + + projectId = projectId or self.get_project_id() + + return self.add_task( + projectId=projectId, + request_data={ + "precedingTaskId": precedingTaskId, + "type": CrowdinTaskType.PROOFREAD, + "title": title, + "description": description, + "assignees": assignees, + "assignedTeams": assignedTeams, + "deadline": deadline, + }, + ) diff --git a/crowdin_api/api_resources/tasks/tests/test_tasks_resources.py b/crowdin_api/api_resources/tasks/tests/test_tasks_resources.py index 518392b..eddcb3c 100644 --- a/crowdin_api/api_resources/tasks/tests/test_tasks_resources.py +++ b/crowdin_api/api_resources/tasks/tests/test_tasks_resources.py @@ -6,16 +6,15 @@ from crowdin_api.api_resources.tasks.enums import ( CrowdinGeneralTaskType, CrowdinTaskStatus, + CrowdinTaskType, GengoCrowdinTaskExpertise, GengoCrowdinTaskPurpose, GengoCrowdinTaskTone, - GengoCrowdinTaskType, OhtCrowdinTaskExpertise, OhtCrowdinTaskType, TaskOperationPatchPath, TranslatedCrowdinTaskExpertise, TranslatedCrowdinTaskSubjects, - TranslatedCrowdinTaskType, ConfigTaskOperationPatchPath, LanguageServiceTaskType, ManualCrowdinTaskType, @@ -211,9 +210,8 @@ def test_add_task(self, m_request, base_absolut_url): "type": CrowdinGeneralTaskType.TRANSLATE, "status": None, "description": None, - "splitFiles": None, + "splitContent": None, "skipAssignedStrings": None, - "skipUntranslatedStrings": None, "includePreTranslatedStringsOnly": None, "labelIds": None, "excludeLabelIds": None, @@ -232,9 +230,8 @@ def test_add_task(self, m_request, base_absolut_url): "type": CrowdinGeneralTaskType.TRANSLATE, "status": CrowdinTaskStatus.TODO, "description": "description", - "splitFiles": False, + "splitContent": False, "skipAssignedStrings": False, - "skipUntranslatedStrings": False, "includePreTranslatedStringsOnly": False, "labelIds": [4, 5, 6], "excludeLabelIds": [7, 8, 9], @@ -251,9 +248,8 @@ def test_add_task(self, m_request, base_absolut_url): "type": CrowdinGeneralTaskType.TRANSLATE, "status": CrowdinTaskStatus.TODO, "description": "description", - "splitFiles": False, + "splitContent": False, "skipAssignedStrings": False, - "skipUntranslatedStrings": False, "includePreTranslatedStringsOnly": False, "labelIds": [4, 5, 6], "excludeLabelIds": [7, 8, 9], @@ -274,6 +270,77 @@ def test_add_general_task(self, m_add_task, incoming_data, request_data, base_ab assert resource.add_general_task(projectId=1, **incoming_data) == "response" m_add_task.assert_called_once_with(projectId=1, request_data=request_data) + @pytest.mark.parametrize( + "incoming_data, request_data", + ( + ( + { + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": CrowdinGeneralTaskType.TRANSLATE, + }, + { + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": CrowdinGeneralTaskType.TRANSLATE, + "status": None, + "description": None, + "splitContent": None, + "skipAssignedStrings": None, + "includePreTranslatedStringsOnly": None, + "assignees": None, + "deadline": None, + "startedAt": None, + "dateFrom": None, + "dateTo": None, + }, + ), + ( + { + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": CrowdinGeneralTaskType.TRANSLATE, + "status": CrowdinTaskStatus.TODO, + "description": "description", + "splitContent": False, + "skipAssignedStrings": False, + "includePreTranslatedStringsOnly": False, + "assignees": [{"id": 1, "wordsCount": 2}], + "deadline": datetime(year=1988, month=9, day=26), + "startedAt": datetime(year=1966, month=2, day=1), + "dateFrom": datetime(year=1988, month=1, day=4), + "dateTo": datetime(year=2015, month=10, day=13), + }, + { + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": CrowdinGeneralTaskType.TRANSLATE, + "status": CrowdinTaskStatus.TODO, + "description": "description", + "splitContent": False, + "skipAssignedStrings": False, + "includePreTranslatedStringsOnly": False, + "assignees": [{"id": 1, "wordsCount": 2}], + "deadline": datetime(year=1988, month=9, day=26), + "startedAt": datetime(year=1966, month=2, day=1), + "dateFrom": datetime(year=1988, month=1, day=4), + "dateTo": datetime(year=2015, month=10, day=13), + }, + ), + ), + ) + @mock.patch("crowdin_api.api_resources.tasks.resource.TasksResource.add_task") + def test_add_general_by_string_ids_task(self, m_add_task, incoming_data, request_data, base_absolut_url): + m_add_task.return_value = "response" + + resource = self.get_resource(base_absolut_url) + assert resource.add_general_by_string_ids_task(projectId=1, **incoming_data) == "response" + m_add_task.assert_called_once_with(projectId=1, request_data=request_data) + @pytest.mark.parametrize( "incoming_data, request_data", ( @@ -294,9 +361,7 @@ def test_add_general_task(self, m_add_task, incoming_data, request_data, base_ab "description": None, "labelIds": None, "excludeLabelIds": None, - "skipUntranslatedStrings": None, "includePreTranslatedStringsOnly": None, - "includeUntranslatedStringsOnly": None, "dateFrom": None, "dateTo": None, }, @@ -311,9 +376,7 @@ def test_add_general_task(self, m_add_task, incoming_data, request_data, base_ab "description": "description", "labelIds": [4, 5, 6], "excludeLabelIds": [7, 8, 9], - "skipUntranslatedStrings": False, "includePreTranslatedStringsOnly": False, - "includeUntranslatedStringsOnly": False, "dateFrom": datetime(year=1988, month=1, day=4), "dateTo": datetime(year=2015, month=10, day=13), }, @@ -327,9 +390,7 @@ def test_add_general_task(self, m_add_task, incoming_data, request_data, base_ab "description": "description", "labelIds": [4, 5, 6], "excludeLabelIds": [7, 8, 9], - "skipUntranslatedStrings": False, "includePreTranslatedStringsOnly": False, - "includeUntranslatedStringsOnly": False, "dateFrom": datetime(year=1988, month=1, day=4), "dateTo": datetime(year=2015, month=10, day=13), }, @@ -346,6 +407,66 @@ def test_add_language_service_task( assert resource.add_language_service_task(projectId=1, **incoming_data) == "response" m_add_task.assert_called_once_with(projectId=1, request_data=request_data) + @pytest.mark.parametrize( + "incoming_data, request_data", + ( + ( + { + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": LanguageServiceTaskType.TRANSLATE_BY_VENDOR, + }, + { + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": LanguageServiceTaskType.TRANSLATE_BY_VENDOR, + "vendor": "crowdin_language_service", + "status": None, + "description": None, + "includePreTranslatedStringsOnly": None, + "dateFrom": None, + "dateTo": None, + }, + ), + ( + { + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": LanguageServiceTaskType.TRANSLATE_BY_VENDOR, + "status": CrowdinTaskStatus.TODO, + "description": "description", + "includePreTranslatedStringsOnly": False, + "dateFrom": datetime(year=1988, month=1, day=4), + "dateTo": datetime(year=2015, month=10, day=13), + }, + { + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": LanguageServiceTaskType.TRANSLATE_BY_VENDOR, + "vendor": "crowdin_language_service", + "status": CrowdinTaskStatus.TODO, + "description": "description", + "includePreTranslatedStringsOnly": False, + "dateFrom": datetime(year=1988, month=1, day=4), + "dateTo": datetime(year=2015, month=10, day=13), + }, + ), + ), + ) + @mock.patch("crowdin_api.api_resources.tasks.resource.TasksResource.add_task") + def test_add_language_service_by_string_ids_task( + self, m_add_task, incoming_data, request_data, base_absolut_url + ): + m_add_task.return_value = "response" + + resource = self.get_resource(base_absolut_url) + assert resource.add_language_service_by_string_ids_task(projectId=1, **incoming_data) == "response" + m_add_task.assert_called_once_with(projectId=1, request_data=request_data) + @pytest.mark.parametrize( "incoming_data, request_data", ( @@ -365,11 +486,10 @@ def test_add_language_service_task( "status": None, "description": None, "expertise": None, + "editService": None, "labelIds": None, "excludeLabelIds": None, - "skipUntranslatedStrings": None, "includePreTranslatedStringsOnly": None, - "includeUntranslatedStringsOnly": None, "dateFrom": None, "dateTo": None, }, @@ -383,11 +503,10 @@ def test_add_language_service_task( "status": CrowdinTaskStatus.TODO, "description": "description", "expertise": OhtCrowdinTaskExpertise.AD_WORDS_BANNERS, + "editService": True, "labelIds": [4, 5, 6], "excludeLabelIds": [7, 8, 9], - "skipUntranslatedStrings": False, "includePreTranslatedStringsOnly": False, - "includeUntranslatedStringsOnly": False, "dateFrom": datetime(year=1988, month=1, day=4), "dateTo": datetime(year=2015, month=10, day=13), }, @@ -400,11 +519,10 @@ def test_add_language_service_task( "status": CrowdinTaskStatus.TODO, "description": "description", "expertise": OhtCrowdinTaskExpertise.AD_WORDS_BANNERS, + "editService": True, "labelIds": [4, 5, 6], "excludeLabelIds": [7, 8, 9], - "skipUntranslatedStrings": False, "includePreTranslatedStringsOnly": False, - "includeUntranslatedStringsOnly": False, "dateFrom": datetime(year=1988, month=1, day=4), "dateTo": datetime(year=2015, month=10, day=13), }, @@ -419,6 +537,70 @@ def test_add_vendor_oht_task(self, m_add_task, incoming_data, request_data, base assert resource.add_vendor_oht_task(projectId=1, **incoming_data) == "response" m_add_task.assert_called_once_with(projectId=1, request_data=request_data) + @pytest.mark.parametrize( + "incoming_data, request_data", + ( + ( + { + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": OhtCrowdinTaskType.TRANSLATE_BY_VENDOR, + }, + { + "vendor": "oht", + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": OhtCrowdinTaskType.TRANSLATE_BY_VENDOR, + "status": None, + "description": None, + "editService": None, + "expertise": None, + "includePreTranslatedStringsOnly": None, + "dateFrom": None, + "dateTo": None, + }, + ), + ( + { + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": OhtCrowdinTaskType.TRANSLATE_BY_VENDOR, + "status": CrowdinTaskStatus.TODO, + "description": "description", + "expertise": OhtCrowdinTaskExpertise.AD_WORDS_BANNERS, + "editService": True, + "includePreTranslatedStringsOnly": False, + "dateFrom": datetime(year=1988, month=1, day=4), + "dateTo": datetime(year=2015, month=10, day=13), + }, + { + "vendor": "oht", + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": OhtCrowdinTaskType.TRANSLATE_BY_VENDOR, + "status": CrowdinTaskStatus.TODO, + "description": "description", + "expertise": OhtCrowdinTaskExpertise.AD_WORDS_BANNERS, + "editService": True, + "includePreTranslatedStringsOnly": False, + "dateFrom": datetime(year=1988, month=1, day=4), + "dateTo": datetime(year=2015, month=10, day=13), + }, + ), + ), + ) + @mock.patch("crowdin_api.api_resources.tasks.resource.TasksResource.add_task") + def test_add_vendor_oht_by_string_ids_task(self, m_add_task, incoming_data, request_data, base_absolut_url): + m_add_task.return_value = "response" + + resource = self.get_resource(base_absolut_url) + assert resource.add_vendor_oht_by_string_ids_task(projectId=1, **incoming_data) == "response" + m_add_task.assert_called_once_with(projectId=1, request_data=request_data) + @pytest.mark.parametrize( "incoming_data, request_data", ( @@ -427,14 +609,13 @@ def test_add_vendor_oht_task(self, m_add_task, incoming_data, request_data, base "title": "title", "languageId": "ua", "fileIds": [1, 2, 3], - "type": GengoCrowdinTaskType.TRANSLATE_BY_VENDOR, }, { "vendor": "gengo", "title": "title", "languageId": "ua", "fileIds": [1, 2, 3], - "type": GengoCrowdinTaskType.TRANSLATE_BY_VENDOR, + "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, "status": None, "description": None, "expertise": None, @@ -454,7 +635,6 @@ def test_add_vendor_oht_task(self, m_add_task, incoming_data, request_data, base "title": "title", "languageId": "ua", "fileIds": [1, 2, 3], - "type": GengoCrowdinTaskType.TRANSLATE_BY_VENDOR, "status": CrowdinTaskStatus.IN_PROGRESS, "description": "description", "expertise": GengoCrowdinTaskExpertise.PRO, @@ -473,7 +653,7 @@ def test_add_vendor_oht_task(self, m_add_task, incoming_data, request_data, base "title": "title", "languageId": "ua", "fileIds": [1, 2, 3], - "type": GengoCrowdinTaskType.TRANSLATE_BY_VENDOR, + "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, "status": CrowdinTaskStatus.IN_PROGRESS, "description": "description", "expertise": GengoCrowdinTaskExpertise.PRO, @@ -505,21 +685,22 @@ def test_add_vendor_gengo_task(self, m_add_task, incoming_data, request_data, ba { "title": "title", "languageId": "ua", - "fileIds": [1, 2, 3], - "type": TranslatedCrowdinTaskType.TRANSLATE_BY_VENDOR, + "stringIds": [1, 2, 3], }, { - "vender": "translated", + "vendor": "gengo", "title": "title", "languageId": "ua", - "fileIds": [1, 2, 3], - "type": TranslatedCrowdinTaskType.TRANSLATE_BY_VENDOR, + "stringIds": [1, 2, 3], + "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, "status": None, "description": None, "expertise": None, - "subject": None, - "labelIds": None, - "excludeLabelIds": None, + "editService": None, + "tone": None, + "purpose": None, + "customerMessage": None, + "usePreferred": None, "dateFrom": None, "dateTo": None, }, @@ -528,29 +709,32 @@ def test_add_vendor_gengo_task(self, m_add_task, incoming_data, request_data, ba { "title": "title", "languageId": "ua", - "fileIds": [1, 2, 3], - "type": TranslatedCrowdinTaskType.TRANSLATE_BY_VENDOR, + "stringIds": [1, 2, 3], "status": CrowdinTaskStatus.IN_PROGRESS, "description": "description", - "expertise": TranslatedCrowdinTaskExpertise.ECONOMY, - "subject": TranslatedCrowdinTaskSubjects.ART, - "labelIds": [4, 5, 6], - "excludeLabelIds": [7, 8, 9], + "expertise": GengoCrowdinTaskExpertise.PRO, + "tone": GengoCrowdinTaskTone.FRIENDLY, + "purpose": GengoCrowdinTaskPurpose.APP_OR_WEB_LOCALIZATION, + "customerMessage": "customer message", + "usePreferred": True, + "editService": True, "dateFrom": datetime(year=1988, month=1, day=4), "dateTo": datetime(year=2015, month=10, day=13), }, { - "vender": "translated", + "vendor": "gengo", "title": "title", "languageId": "ua", - "fileIds": [1, 2, 3], - "type": TranslatedCrowdinTaskType.TRANSLATE_BY_VENDOR, + "stringIds": [1, 2, 3], + "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, "status": CrowdinTaskStatus.IN_PROGRESS, "description": "description", - "expertise": TranslatedCrowdinTaskExpertise.ECONOMY, - "subject": TranslatedCrowdinTaskSubjects.ART, - "labelIds": [4, 5, 6], - "excludeLabelIds": [7, 8, 9], + "expertise": GengoCrowdinTaskExpertise.PRO, + "tone": GengoCrowdinTaskTone.FRIENDLY, + "purpose": GengoCrowdinTaskPurpose.APP_OR_WEB_LOCALIZATION, + "customerMessage": "customer message", + "usePreferred": True, + "editService": True, "dateFrom": datetime(year=1988, month=1, day=4), "dateTo": datetime(year=2015, month=10, day=13), }, @@ -558,13 +742,11 @@ def test_add_vendor_gengo_task(self, m_add_task, incoming_data, request_data, ba ), ) @mock.patch("crowdin_api.api_resources.tasks.resource.TasksResource.add_task") - def test_add_vendor_translated_task( - self, m_add_task, incoming_data, request_data, base_absolut_url - ): + def test_add_vendor_gengo_by_string_ids_task(self, m_add_task, incoming_data, request_data, base_absolut_url): m_add_task.return_value = "response" resource = self.get_resource(base_absolut_url) - assert resource.add_vendor_translated_task(projectId=1, **incoming_data) == "response" + assert resource.add_vendor_gengo_by_string_ids_task(projectId=1, **incoming_data) == "response" m_add_task.assert_called_once_with(projectId=1, request_data=request_data) @pytest.mark.parametrize( @@ -575,25 +757,19 @@ def test_add_vendor_translated_task( "title": "title", "languageId": "ua", "fileIds": [1, 2, 3], - "type": ManualCrowdinTaskType.TRANSLATE_BY_VENDOR, - "vendor": ManualCrowdinVendors.ACCLARO, }, { + "vendor": "translated", "title": "title", "languageId": "ua", "fileIds": [1, 2, 3], - "type": ManualCrowdinTaskType.TRANSLATE_BY_VENDOR, - "vendor": ManualCrowdinVendors.ACCLARO, + "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, "status": None, "description": None, - "skipAssignedStrings": None, - "skipUntranslatedStrings": None, - "includePreTranslatedStringsOnly": None, + "expertise": None, + "subject": None, "labelIds": None, "excludeLabelIds": None, - "assignees": None, - "deadline": None, - "startedAt": None, "dateFrom": None, "dateTo": None, }, @@ -603,37 +779,168 @@ def test_add_vendor_translated_task( "title": "title", "languageId": "ua", "fileIds": [1, 2, 3], - "type": ManualCrowdinTaskType.TRANSLATE_BY_VENDOR, - "vendor": ManualCrowdinVendors.ACCLARO, - "status": CrowdinTaskStatus.TODO, + "status": CrowdinTaskStatus.IN_PROGRESS, "description": "description", - "skipAssignedStrings": False, - "skipUntranslatedStrings": False, - "includePreTranslatedStringsOnly": False, - "labelIds": [1, 2, 3], - "excludeLabelIds": [4, 5, 6], - "assignees": [{"id": 1, "wordsCount": 2}], - "deadline": datetime(year=1988, month=9, day=26), - "startedAt": datetime(year=1966, month=2, day=1), + "expertise": TranslatedCrowdinTaskExpertise.ECONOMY, + "subject": TranslatedCrowdinTaskSubjects.ART, + "labelIds": [4, 5, 6], + "excludeLabelIds": [7, 8, 9], "dateFrom": datetime(year=1988, month=1, day=4), "dateTo": datetime(year=2015, month=10, day=13), }, { + "vendor": "translated", "title": "title", "languageId": "ua", "fileIds": [1, 2, 3], - "type": ManualCrowdinTaskType.TRANSLATE_BY_VENDOR, - "vendor": ManualCrowdinVendors.ACCLARO, - "status": CrowdinTaskStatus.TODO, + "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, + "status": CrowdinTaskStatus.IN_PROGRESS, "description": "description", - "skipAssignedStrings": False, - "skipUntranslatedStrings": False, - "includePreTranslatedStringsOnly": False, - "labelIds": [1, 2, 3], - "excludeLabelIds": [4, 5, 6], - "assignees": [{"id": 1, "wordsCount": 2}], - "deadline": datetime(year=1988, month=9, day=26), - "startedAt": datetime(year=1966, month=2, day=1), + "expertise": TranslatedCrowdinTaskExpertise.ECONOMY, + "subject": TranslatedCrowdinTaskSubjects.ART, + "labelIds": [4, 5, 6], + "excludeLabelIds": [7, 8, 9], + "dateFrom": datetime(year=1988, month=1, day=4), + "dateTo": datetime(year=2015, month=10, day=13), + }, + ), + ), + ) + @mock.patch("crowdin_api.api_resources.tasks.resource.TasksResource.add_task") + def test_add_vendor_translated_task( + self, m_add_task, incoming_data, request_data, base_absolut_url + ): + m_add_task.return_value = "response" + + resource = self.get_resource(base_absolut_url) + assert resource.add_vendor_translated_task(projectId=1, **incoming_data) == "response" + m_add_task.assert_called_once_with(projectId=1, request_data=request_data) + + @pytest.mark.parametrize( + "incoming_data, request_data", + ( + ( + { + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + }, + { + "vendor": "translated", + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, + "status": None, + "description": None, + "expertise": None, + "subject": None, + "dateFrom": None, + "dateTo": None, + }, + ), + ( + { + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "status": CrowdinTaskStatus.IN_PROGRESS, + "description": "description", + "expertise": TranslatedCrowdinTaskExpertise.ECONOMY, + "subject": TranslatedCrowdinTaskSubjects.ART, + "dateFrom": datetime(year=1988, month=1, day=4), + "dateTo": datetime(year=2015, month=10, day=13), + }, + { + "vendor": "translated", + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, + "status": CrowdinTaskStatus.IN_PROGRESS, + "description": "description", + "expertise": TranslatedCrowdinTaskExpertise.ECONOMY, + "subject": TranslatedCrowdinTaskSubjects.ART, + "dateFrom": datetime(year=1988, month=1, day=4), + "dateTo": datetime(year=2015, month=10, day=13), + }, + ), + ), + ) + @mock.patch("crowdin_api.api_resources.tasks.resource.TasksResource.add_task") + def test_add_vendor_translated_by_string_ids_task( + self, m_add_task, incoming_data, request_data, base_absolut_url + ): + m_add_task.return_value = "response" + + resource = self.get_resource(base_absolut_url) + assert resource.add_vendor_translated_by_string_ids_task(projectId=1, **incoming_data) == "response" + m_add_task.assert_called_once_with(projectId=1, request_data=request_data) + + @pytest.mark.parametrize( + "incoming_data, request_data", + ( + ( + { + "title": "title", + "languageId": "ua", + "fileIds": [1, 2, 3], + "type": ManualCrowdinTaskType.TRANSLATE_BY_VENDOR, + "vendor": ManualCrowdinVendors.ACCLARO, + }, + { + "title": "title", + "languageId": "ua", + "fileIds": [1, 2, 3], + "type": ManualCrowdinTaskType.TRANSLATE_BY_VENDOR, + "vendor": ManualCrowdinVendors.ACCLARO, + "status": None, + "description": None, + "skipAssignedStrings": None, + "includePreTranslatedStringsOnly": None, + "labelIds": None, + "excludeLabelIds": None, + "assignees": None, + "deadline": None, + "startedAt": None, + "dateFrom": None, + "dateTo": None, + }, + ), + ( + { + "title": "title", + "languageId": "ua", + "fileIds": [1, 2, 3], + "type": ManualCrowdinTaskType.TRANSLATE_BY_VENDOR, + "vendor": ManualCrowdinVendors.ACCLARO, + "status": CrowdinTaskStatus.TODO, + "description": "description", + "skipAssignedStrings": False, + "includePreTranslatedStringsOnly": False, + "labelIds": [1, 2, 3], + "excludeLabelIds": [4, 5, 6], + "assignees": [{"id": 1, "wordsCount": 2}], + "deadline": datetime(year=1988, month=9, day=26), + "startedAt": datetime(year=1966, month=2, day=1), + "dateFrom": datetime(year=1988, month=1, day=4), + "dateTo": datetime(year=2015, month=10, day=13), + }, + { + "title": "title", + "languageId": "ua", + "fileIds": [1, 2, 3], + "type": ManualCrowdinTaskType.TRANSLATE_BY_VENDOR, + "vendor": ManualCrowdinVendors.ACCLARO, + "status": CrowdinTaskStatus.TODO, + "description": "description", + "skipAssignedStrings": False, + "includePreTranslatedStringsOnly": False, + "labelIds": [1, 2, 3], + "excludeLabelIds": [4, 5, 6], + "assignees": [{"id": 1, "wordsCount": 2}], + "deadline": datetime(year=1988, month=9, day=26), + "startedAt": datetime(year=1966, month=2, day=1), "dateFrom": datetime(year=1988, month=1, day=4), "dateTo": datetime(year=2015, month=10, day=13), }, @@ -650,6 +957,221 @@ def test_add_vendor_manual_task( assert resource.add_vendor_manual_task(projectId=1, **incoming_data) == "response" m_add_task.assert_called_once_with(projectId=1, request_data=request_data) + @pytest.mark.parametrize( + "incoming_data, request_data", + ( + ( + { + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": ManualCrowdinTaskType.TRANSLATE_BY_VENDOR, + "vendor": ManualCrowdinVendors.ACCLARO, + }, + { + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": ManualCrowdinTaskType.TRANSLATE_BY_VENDOR, + "vendor": ManualCrowdinVendors.ACCLARO, + "status": None, + "description": None, + "skipAssignedStrings": None, + "includePreTranslatedStringsOnly": None, + "assignees": None, + "deadline": None, + "startedAt": None, + "dateFrom": None, + "dateTo": None, + }, + ), + ( + { + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": ManualCrowdinTaskType.TRANSLATE_BY_VENDOR, + "vendor": ManualCrowdinVendors.ACCLARO, + "status": CrowdinTaskStatus.TODO, + "description": "description", + "skipAssignedStrings": False, + "includePreTranslatedStringsOnly": False, + "assignees": [{"id": 1, "wordsCount": 2}], + "deadline": datetime(year=1988, month=9, day=26), + "startedAt": datetime(year=1966, month=2, day=1), + "dateFrom": datetime(year=1988, month=1, day=4), + "dateTo": datetime(year=2015, month=10, day=13), + }, + { + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": ManualCrowdinTaskType.TRANSLATE_BY_VENDOR, + "vendor": ManualCrowdinVendors.ACCLARO, + "status": CrowdinTaskStatus.TODO, + "description": "description", + "skipAssignedStrings": False, + "includePreTranslatedStringsOnly": False, + "assignees": [{"id": 1, "wordsCount": 2}], + "deadline": datetime(year=1988, month=9, day=26), + "startedAt": datetime(year=1966, month=2, day=1), + "dateFrom": datetime(year=1988, month=1, day=4), + "dateTo": datetime(year=2015, month=10, day=13), + }, + ), + ), + ) + @mock.patch("crowdin_api.api_resources.tasks.resource.TasksResource.add_task") + def test_add_vendor_manual_by_string_ids_task( + self, m_add_task, incoming_data, request_data, base_absolut_url + ): + m_add_task.return_value = "response" + + resource = self.get_resource(base_absolut_url) + assert resource.add_vendor_manual_by_string_ids_task(projectId=1, **incoming_data) == "response" + m_add_task.assert_called_once_with(projectId=1, request_data=request_data) + + @pytest.mark.parametrize( + "incoming_data, request_data", + ( + ( + { + "title": "title", + "precedingTaskId": 1, + }, + { + "title": "title", + "precedingTaskId": 1, + "type": CrowdinTaskType.PROOFREAD, + "description": None, + "assignees": None, + "deadline": None, + }, + ), + ( + { + "title": "title", + "precedingTaskId": 1, + "description": "description", + "assignees": [{"id": 1, "wordsCount": 2}], + "deadline": datetime(year=1988, month=9, day=26), + }, + { + "title": "title", + "precedingTaskId": 1, + "description": "description", + "assignees": [{"id": 1, "wordsCount": 2}], + "deadline": datetime(year=1988, month=9, day=26), + "type": CrowdinTaskType.PROOFREAD, + }, + ), + ), + ) + @mock.patch("crowdin_api.api_resources.tasks.resource.TasksResource.add_task") + def test_add_pending_task( + self, m_add_task, incoming_data, request_data, base_absolut_url + ): + m_add_task.return_value = "response" + + resource = self.get_resource(base_absolut_url) + assert resource.add_pending_task(projectId=1, **incoming_data) == "response" + m_add_task.assert_called_once_with(projectId=1, request_data=request_data) + + @pytest.mark.parametrize( + "incoming_data, request_data", + ( + ( + { + "title": "title", + "precedingTaskId": 1, + }, + { + "title": "title", + "precedingTaskId": 1, + "type": LanguageServiceTaskType.PROOFREAD_BY_VENDOR, + "vendor": "crowdin_language_service", + "description": None, + "deadline": None, + }, + ), + ( + { + "title": "title", + "precedingTaskId": 1, + "description": "description", + "deadline": datetime(year=1988, month=9, day=26), + }, + { + "title": "title", + "precedingTaskId": 1, + "description": "description", + "deadline": datetime(year=1988, month=9, day=26), + "type": LanguageServiceTaskType.PROOFREAD_BY_VENDOR, + "vendor": "crowdin_language_service", + }, + ), + ), + ) + @mock.patch("crowdin_api.api_resources.tasks.resource.TasksResource.add_task") + def test_add_language_service_pending_task( + self, m_add_task, incoming_data, request_data, base_absolut_url + ): + m_add_task.return_value = "response" + + resource = self.get_resource(base_absolut_url) + assert resource.add_language_service_pending_task(projectId=1, **incoming_data) == "response" + m_add_task.assert_called_once_with(projectId=1, request_data=request_data) + + @pytest.mark.parametrize( + "incoming_data, request_data", + ( + ( + { + "title": "title", + "precedingTaskId": 1, + "vendor": ManualCrowdinVendors.ACCLARO, + }, + { + "title": "title", + "precedingTaskId": 1, + "type": ManualCrowdinTaskType.PROOFREAD_BY_VENDOR, + "vendor": ManualCrowdinVendors.ACCLARO, + "description": None, + "assignees": None, + "deadline": None, + }, + ), + ( + { + "title": "title", + "precedingTaskId": 1, + "description": "description", + "vendor": ManualCrowdinVendors.ACCLARO, + "assignees": [{"id": 1, "wordsCount": 2}], + "deadline": datetime(year=1988, month=9, day=26), + }, + { + "title": "title", + "precedingTaskId": 1, + "description": "description", + "deadline": datetime(year=1988, month=9, day=26), + "type": ManualCrowdinTaskType.PROOFREAD_BY_VENDOR, + "vendor": ManualCrowdinVendors.ACCLARO, + "assignees": [{"id": 1, "wordsCount": 2}], + }, + ), + ), + ) + @mock.patch("crowdin_api.api_resources.tasks.resource.TasksResource.add_task") + def test_add_vendor_manual_pending_task( + self, m_add_task, incoming_data, request_data, base_absolut_url + ): + m_add_task.return_value = "response" + + resource = self.get_resource(base_absolut_url) + assert resource.add_vendor_manual_pending_task(projectId=1, **incoming_data) == "response" + m_add_task.assert_called_once_with(projectId=1, request_data=request_data) + @mock.patch("crowdin_api.requester.APIRequester.request") def test_export_task_strings(self, m_request, base_absolut_url): m_request.return_value = "response" @@ -676,101 +1198,457 @@ def test_delete_task(self, m_request, base_absolut_url): m_request.return_value = "response" resource = self.get_resource(base_absolut_url) - assert resource.delete_task(projectId=1, taskId=2) == "response" - m_request.assert_called_once_with( - method="delete", path=resource.get_tasks_path(projectId=1, taskId=2) - ) - - @mock.patch("crowdin_api.requester.APIRequester.request") - def test_edit_task(self, m_request, base_absolut_url): - m_request.return_value = "response" + assert resource.delete_task(projectId=1, taskId=2) == "response" + m_request.assert_called_once_with( + method="delete", path=resource.get_tasks_path(projectId=1, taskId=2) + ) + + @mock.patch("crowdin_api.requester.APIRequester.request") + def test_edit_task(self, m_request, base_absolut_url): + m_request.return_value = "response" + + data = [ + { + "value": "value", + "op": PatchOperation.REPLACE, + "path": TaskOperationPatchPath.TITLE, + } + ] + + resource = self.get_resource(base_absolut_url) + assert resource.edit_task(projectId=1, taskId=2, data=data) == "response" + m_request.assert_called_once_with( + method="patch", + request_data=data, + path=resource.get_tasks_path(projectId=1, taskId=2), + ) + + @pytest.mark.parametrize( + "incoming_data, request_params", + ( + ({}, {"status": None, "offset": 0, "limit": 25}), + ( + {"status": CrowdinTaskStatus.TODO, "isArchived": False}, + { + "status": CrowdinTaskStatus.TODO, + "isArchived": False, + "offset": 0, + "limit": 25, + }, + ), + ), + ) + @mock.patch("crowdin_api.requester.APIRequester.request") + def test_list_user_tasks(self, m_request, incoming_data, request_params, base_absolut_url): + m_request.return_value = "response" + + resource = self.get_resource(base_absolut_url) + assert resource.list_user_tasks(**incoming_data) == "response" + m_request.assert_called_once_with( + method="get", + params=request_params, + path="user/tasks", + ) + + @mock.patch("crowdin_api.requester.APIRequester.request") + def test_edit_task_archived_status(self, m_request, base_absolut_url): + m_request.return_value = "response" + + resource = self.get_resource(base_absolut_url) + assert ( + resource.edit_task_archived_status(projectId=1, taskId=2, isArchived=False) + == "response" + ) + m_request.assert_called_once_with( + method="patch", + path="user/tasks/2", + params={"projectId": 1}, + request_data=[{"op": "replace", "path": "/isArchived", "value": False}], + ) + + +class TestEnterpriseTasksResource: + resource_class = EnterpriseTasksResource + + def get_resource(self, base_absolut_url): + return self.resource_class(requester=APIRequester(base_url=base_absolut_url)) + + @mock.patch("crowdin_api.requester.APIRequester.request") + def test_add_task_settings_template(self, m_request, base_absolut_url): + m_request.return_value = "response" + input_name = "test template" + input_config_data = { + "languages": [ + { + "languageId": "uk", + "userIds": [1], + "teamIds": [1] + } + ] + } + + resource = self.get_resource(base_absolut_url) + assert resource.add_task_settings_template( + projectId=1, name=input_name, config=input_config_data + ) == "response" + m_request.assert_called_once_with( + method="post", + path=resource.get_task_settings_templates_path(projectId=1), + request_data={"name": input_name, "config": input_config_data}, + ) + + @pytest.mark.parametrize( + "incoming_data, request_data", + ( + ( + { + "title": "title", + "languageId": "ua", + "fileIds": [1, 2, 3], + "type": CrowdinGeneralTaskType.TRANSLATE, + }, + { + "title": "title", + "languageId": "ua", + "fileIds": [1, 2, 3], + "type": CrowdinGeneralTaskType.TRANSLATE, + "workflowStepId": None, + "status": None, + "description": None, + "splitContent": None, + "skipAssignedStrings": None, + "includePreTranslatedStringsOnly": None, + "labelIds": None, + "excludeLabelIds": None, + "assignees": None, + "assignedTeams": None, + "deadline": None, + "startedAt": None, + "dateFrom": None, + "dateTo": None, + }, + ), + ( + { + "title": "title", + "languageId": "ua", + "fileIds": [1, 2, 3], + "workflowStepId": 1, + "type": CrowdinGeneralTaskType.TRANSLATE, + "status": CrowdinTaskStatus.TODO, + "description": "description", + "splitContent": True, + "skipAssignedStrings": True, + "includePreTranslatedStringsOnly": True, + "labelIds": [1, 2, 3], + "excludeLabelIds": [4, 5, 6], + "assignees": [{"id": 1, "wordsCount": 2}], + "assignedTeams": [{"id": 1, "wordsCount": 2}], + "deadline": datetime(year=1988, month=9, day=26), + "startedAt": datetime(year=1966, month=2, day=1), + "dateFrom": datetime(year=1988, month=1, day=4), + "dateTo": datetime(year=2015, month=10, day=13), + }, + { + "title": "title", + "languageId": "ua", + "fileIds": [1, 2, 3], + "type": CrowdinGeneralTaskType.TRANSLATE, + "workflowStepId": 1, + "status": CrowdinTaskStatus.TODO, + "description": "description", + "splitContent": True, + "skipAssignedStrings": True, + "includePreTranslatedStringsOnly": True, + "labelIds": [1, 2, 3], + "excludeLabelIds": [4, 5, 6], + "assignees": [{"id": 1, "wordsCount": 2}], + "assignedTeams": [{"id": 1, "wordsCount": 2}], + "deadline": datetime(year=1988, month=9, day=26), + "startedAt": datetime(year=1966, month=2, day=1), + "dateFrom": datetime(year=1988, month=1, day=4), + "dateTo": datetime(year=2015, month=10, day=13), + }, + ), + ), + ) + @mock.patch( + "crowdin_api.api_resources.tasks.resource.EnterpriseTasksResource.add_task" + ) + def test_add_general_task( + self, m_add_task, incoming_data, request_data, base_absolut_url + ): + m_add_task.return_value = "response" + + resource = self.get_resource(base_absolut_url) + assert resource.add_general_task(projectId=1, **incoming_data) == "response" + m_add_task.assert_called_once_with(projectId=1, request_data=request_data) - data = [ - { - "value": "value", - "op": PatchOperation.REPLACE, - "path": TaskOperationPatchPath.TITLE, - } - ] + @pytest.mark.parametrize( + "incoming_data, request_data", + ( + ( + { + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": CrowdinGeneralTaskType.TRANSLATE, + }, + { + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": CrowdinGeneralTaskType.TRANSLATE, + "workflowStepId": None, + "status": None, + "description": None, + "splitContent": None, + "skipAssignedStrings": None, + "includePreTranslatedStringsOnly": None, + "assignees": None, + "assignedTeams": None, + "deadline": None, + "startedAt": None, + "dateFrom": None, + "dateTo": None, + }, + ), + ( + { + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "workflowStepId": 1, + "status": CrowdinTaskStatus.TODO, + "description": "description", + "splitContent": True, + "skipAssignedStrings": True, + "includePreTranslatedStringsOnly": True, + "assignees": [{"id": 1, "wordsCount": 2}], + "assignedTeams": [{"id": 1, "wordsCount": 2}], + "deadline": datetime(year=1988, month=9, day=26), + "startedAt": datetime(year=1966, month=2, day=1), + "dateFrom": datetime(year=1988, month=1, day=4), + "dateTo": datetime(year=2015, month=10, day=13), + }, + { + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "workflowStepId": 1, + "type": None, + "status": CrowdinTaskStatus.TODO, + "description": "description", + "splitContent": True, + "skipAssignedStrings": True, + "includePreTranslatedStringsOnly": True, + "assignees": [{"id": 1, "wordsCount": 2}], + "assignedTeams": [{"id": 1, "wordsCount": 2}], + "deadline": datetime(year=1988, month=9, day=26), + "startedAt": datetime(year=1966, month=2, day=1), + "dateFrom": datetime(year=1988, month=1, day=4), + "dateTo": datetime(year=2015, month=10, day=13), + }, + ), + ), + ) + @mock.patch( + "crowdin_api.api_resources.tasks.resource.EnterpriseTasksResource.add_task" + ) + def test_add_general_by_string_ids_task( + self, m_add_task, incoming_data, request_data, base_absolut_url + ): + m_add_task.return_value = "response" resource = self.get_resource(base_absolut_url) - assert resource.edit_task(projectId=1, taskId=2, data=data) == "response" - m_request.assert_called_once_with( - method="patch", - request_data=data, - path=resource.get_tasks_path(projectId=1, taskId=2), + assert ( + resource.add_general_by_string_ids_task(projectId=1, **incoming_data) + == "response" ) + m_add_task.assert_called_once_with(projectId=1, request_data=request_data) @pytest.mark.parametrize( - "incoming_data, request_params", + "incoming_data, request_data", ( - ({}, {"status": None, "offset": 0, "limit": 25}), ( - {"status": CrowdinTaskStatus.TODO, "isArchived": False}, { - "status": CrowdinTaskStatus.TODO, - "isArchived": False, - "offset": 0, - "limit": 25, + "title": "title", + "languageId": "ua", + "workflowStepId": 1, + "fileIds": [1, 2, 3], + }, + { + "title": "title", + "languageId": "ua", + "workflowStepId": 1, + "fileIds": [1, 2, 3], + "description": None, + "skipAssignedStrings": None, + "includePreTranslatedStringsOnly": None, + "labelIds": None, + "excludeLabelIds": None, + "deadline": None, + "startedAt": None, + "dateTo": None, + }, + ), + ( + { + "title": "title", + "languageId": "ua", + "workflowStepId": 1, + "fileIds": [1, 2, 3], + "description": "description", + "skipAssignedStrings": True, + "includePreTranslatedStringsOnly": True, + "labelIds": [1, 2, 3], + "excludeLabelIds": [4, 5, 6], + "deadline": datetime(year=1988, month=9, day=26), + "startedAt": datetime(year=1966, month=2, day=1), + "dateTo": datetime(year=2015, month=10, day=13), + }, + { + "title": "title", + "languageId": "ua", + "workflowStepId": 1, + "fileIds": [1, 2, 3], + "description": "description", + "skipAssignedStrings": True, + "includePreTranslatedStringsOnly": True, + "labelIds": [1, 2, 3], + "excludeLabelIds": [4, 5, 6], + "deadline": datetime(year=1988, month=9, day=26), + "startedAt": datetime(year=1966, month=2, day=1), + "dateTo": datetime(year=2015, month=10, day=13), }, ), ), ) - @mock.patch("crowdin_api.requester.APIRequester.request") - def test_list_user_tasks(self, m_request, incoming_data, request_params, base_absolut_url): - m_request.return_value = "response" + @mock.patch( + "crowdin_api.api_resources.tasks.resource.EnterpriseTasksResource.add_task" + ) + def test_add_vendor_task( + self, m_add_task, incoming_data, request_data, base_absolut_url + ): + m_add_task.return_value = "response" resource = self.get_resource(base_absolut_url) - assert resource.list_user_tasks(**incoming_data) == "response" - m_request.assert_called_once_with( - method="get", - params=request_params, - path="user/tasks", - ) + assert resource.add_vendor_task(projectId=1, **incoming_data) == "response" + m_add_task.assert_called_once_with(projectId=1, request_data=request_data) - @mock.patch("crowdin_api.requester.APIRequester.request") - def test_edit_task_archived_status(self, m_request, base_absolut_url): - m_request.return_value = "response" + @pytest.mark.parametrize( + "incoming_data, request_data", + ( + ( + { + "title": "title", + "languageId": "ua", + "workflowStepId": 1, + "stringIds": [1, 2, 3], + }, + { + "title": "title", + "languageId": "ua", + "workflowStepId": 1, + "stringIds": [1, 2, 3], + "description": None, + "skipAssignedStrings": None, + "includePreTranslatedStringsOnly": None, + "deadline": None, + "startedAt": None, + "dateTo": None, + }, + ), + ( + { + "title": "title", + "languageId": "ua", + "workflowStepId": 1, + "stringIds": [1, 2, 3], + "description": "description", + "skipAssignedStrings": True, + "includePreTranslatedStringsOnly": True, + "deadline": datetime(year=1988, month=9, day=26), + "startedAt": datetime(year=1966, month=2, day=1), + "dateTo": datetime(year=2015, month=10, day=13), + }, + { + "title": "title", + "languageId": "ua", + "workflowStepId": 1, + "stringIds": [1, 2, 3], + "description": "description", + "skipAssignedStrings": True, + "includePreTranslatedStringsOnly": True, + "deadline": datetime(year=1988, month=9, day=26), + "startedAt": datetime(year=1966, month=2, day=1), + "dateTo": datetime(year=2015, month=10, day=13), + }, + ), + ), + ) + @mock.patch( + "crowdin_api.api_resources.tasks.resource.EnterpriseTasksResource.add_task" + ) + def test_add_vendor_by_string_ids_task( + self, m_add_task, incoming_data, request_data, base_absolut_url + ): + m_add_task.return_value = "response" resource = self.get_resource(base_absolut_url) assert ( - resource.edit_task_archived_status(projectId=1, taskId=2, isArchived=False) + resource.add_vendor_by_string_ids_task(projectId=1, **incoming_data) == "response" ) - m_request.assert_called_once_with( - method="patch", - path="user/tasks/2", - params={"projectId": 1}, - request_data=[{"op": "replace", "path": "/isArchived", "value": False}], - ) - - -class TestEnterpriseTasksResource: - resource_class = EnterpriseTasksResource - - def get_resource(self, base_absolut_url): - return self.resource_class(requester=APIRequester(base_url=base_absolut_url)) + m_add_task.assert_called_once_with(projectId=1, request_data=request_data) - @mock.patch("crowdin_api.requester.APIRequester.request") - def test_add_task_settings_template(self, m_request, base_absolut_url): - m_request.return_value = "response" - input_name = "test template" - input_config_data = { - "languages": [ + @pytest.mark.parametrize( + "incoming_data, request_data", + ( + ( { - "languageId": "uk", - "userIds": [1], - "teamIds": [1] - } - ] - } + "title": "title", + "precedingTaskId": 1, + }, + { + "title": "title", + "precedingTaskId": 1, + "type": CrowdinTaskType.PROOFREAD, + "description": None, + "assignees": None, + "assignedTeams": None, + "deadline": None, + }, + ), + ( + { + "title": "title", + "precedingTaskId": 1, + "description": "description", + "assignees": [{"id": 1, "wordsCount": 2}], + "assignedTeams": [{"id": 1, "wordsCount": 2}], + "deadline": datetime(year=1988, month=9, day=26), + }, + { + "title": "title", + "precedingTaskId": 1, + "type": CrowdinTaskType.PROOFREAD, + "description": "description", + "assignees": [{"id": 1, "wordsCount": 2}], + "assignedTeams": [{"id": 1, "wordsCount": 2}], + "deadline": datetime(year=1988, month=9, day=26), + }, + ), + ), + ) + @mock.patch( + "crowdin_api.api_resources.tasks.resource.EnterpriseTasksResource.add_task" + ) + def test_add_pending_task( + self, m_add_task, incoming_data, request_data, base_absolut_url + ): + m_add_task.return_value = "response" resource = self.get_resource(base_absolut_url) - assert resource.add_task_settings_template( - projectId=1, name=input_name, config=input_config_data - ) == "response" - m_request.assert_called_once_with( - method="post", - path=resource.get_task_settings_templates_path(projectId=1), - request_data={"name": input_name, "config": input_config_data}, - ) + assert resource.add_pending_task(projectId=1, **incoming_data) == "response" + m_add_task.assert_called_once_with(projectId=1, request_data=request_data) diff --git a/crowdin_api/api_resources/tasks/types.py b/crowdin_api/api_resources/tasks/types.py index 3156439..d32f6b8 100644 --- a/crowdin_api/api_resources/tasks/types.py +++ b/crowdin_api/api_resources/tasks/types.py @@ -41,6 +41,11 @@ class TaskSettingsTemplateLanguages(TypedDict): languages: Iterable[TaskSettingsTemplateConfigLanguage] +class EnterpriseTaskAssignedTeams(TypedDict, total=False): + id: int + wordsCount: int + + class EnterpriseTaskSettingsTemplateConfigLanguage(TypedDict): languageId: str userIds: Optional[Iterable[int]]