From 7aef09308d003ebf72891939865eaa493d3cd73e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Chr=C3=A1stek?= Date: Mon, 2 Dec 2024 11:35:35 +0100 Subject: [PATCH 1/6] Fix typo in add_vendor_translated_task --- crowdin_api/api_resources/tasks/resource.py | 2 +- crowdin_api/api_resources/tasks/tests/test_tasks_resources.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crowdin_api/api_resources/tasks/resource.py b/crowdin_api/api_resources/tasks/resource.py index b3dc0d4..b8e1f79 100644 --- a/crowdin_api/api_resources/tasks/resource.py +++ b/crowdin_api/api_resources/tasks/resource.py @@ -455,7 +455,7 @@ def add_vendor_translated_task( "excludeLabelIds": excludeLabelIds, "dateFrom": dateFrom, "dateTo": dateTo, - "vender": "translated", + "vendor": "translated", }, ) 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..c0bb44d 100644 --- a/crowdin_api/api_resources/tasks/tests/test_tasks_resources.py +++ b/crowdin_api/api_resources/tasks/tests/test_tasks_resources.py @@ -509,7 +509,7 @@ def test_add_vendor_gengo_task(self, m_add_task, incoming_data, request_data, ba "type": TranslatedCrowdinTaskType.TRANSLATE_BY_VENDOR, }, { - "vender": "translated", + "vendor": "translated", "title": "title", "languageId": "ua", "fileIds": [1, 2, 3], @@ -540,7 +540,7 @@ def test_add_vendor_gengo_task(self, m_add_task, incoming_data, request_data, ba "dateTo": datetime(year=2015, month=10, day=13), }, { - "vender": "translated", + "vendor": "translated", "title": "title", "languageId": "ua", "fileIds": [1, 2, 3], From cc4bdde592aa076b7962841a828a76c4aa4aba21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Chr=C3=A1stek?= Date: Mon, 2 Dec 2024 11:36:28 +0100 Subject: [PATCH 2/6] Add all Pending Task endpoints for Crowdin.com --- crowdin_api/api_resources/tasks/resource.py | 83 ++++++++++ .../tasks/tests/test_tasks_resources.py | 142 ++++++++++++++++++ 2 files changed, 225 insertions(+) diff --git a/crowdin_api/api_resources/tasks/resource.py b/crowdin_api/api_resources/tasks/resource.py index b8e1f79..5430389 100644 --- a/crowdin_api/api_resources/tasks/resource.py +++ b/crowdin_api/api_resources/tasks/resource.py @@ -5,6 +5,7 @@ from crowdin_api.api_resources.tasks.enums import ( CrowdinGeneralTaskType, CrowdinTaskStatus, + CrowdinTaskType, LanguageServiceTaskType, GengoCrowdinTaskExpertise, GengoCrowdinTaskPurpose, @@ -512,6 +513,88 @@ def add_vendor_manual_task( }, ) + 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. 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 c0bb44d..bf0f98d 100644 --- a/crowdin_api/api_resources/tasks/tests/test_tasks_resources.py +++ b/crowdin_api/api_resources/tasks/tests/test_tasks_resources.py @@ -6,6 +6,7 @@ from crowdin_api.api_resources.tasks.enums import ( CrowdinGeneralTaskType, CrowdinTaskStatus, + CrowdinTaskType, GengoCrowdinTaskExpertise, GengoCrowdinTaskPurpose, GengoCrowdinTaskTone, @@ -650,6 +651,147 @@ 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", + "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" From 65393e4e26506ab5744018424750c47871eb17a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Chr=C3=A1stek?= Date: Mon, 2 Dec 2024 13:11:45 +0100 Subject: [PATCH 3/6] Add Enterprise "Add Task" methods --- crowdin_api/api_resources/tasks/resource.py | 225 +++++++++++ .../tasks/tests/test_tasks_resources.py | 361 ++++++++++++++++++ crowdin_api/api_resources/tasks/types.py | 5 + 3 files changed, 591 insertions(+) diff --git a/crowdin_api/api_resources/tasks/resource.py b/crowdin_api/api_resources/tasks/resource.py index 5430389..84763c4 100644 --- a/crowdin_api/api_resources/tasks/resource.py +++ b/crowdin_api/api_resources/tasks/resource.py @@ -21,6 +21,7 @@ ) from crowdin_api.api_resources.tasks.types import ( CrowdinTaskAssignee, + EnterpriseTaskAssignedTeams, TaskPatchRequest, VendorPatchRequest, ConfigPatchRequest, @@ -738,3 +739,227 @@ 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: 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, + skipUntranslatedStrings: 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, + "skipUntranslatedStrings": skipUntranslatedStrings, + "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, + skipUntranslatedStrings: 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, + "skipUntranslatedStrings": skipUntranslatedStrings, + "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 bf0f98d..3c151a0 100644 --- a/crowdin_api/api_resources/tasks/tests/test_tasks_resources.py +++ b/crowdin_api/api_resources/tasks/tests/test_tasks_resources.py @@ -916,3 +916,364 @@ def test_add_task_settings_template(self, m_request, base_absolut_url): 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, + "skipUntranslatedStrings": 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, + "status": CrowdinTaskStatus.TODO, + "description": "description", + "splitContent": True, + "skipAssignedStrings": True, + "skipUntranslatedStrings": 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": None, + "workflowStepId": 1, + "status": CrowdinTaskStatus.TODO, + "description": "description", + "splitContent": True, + "skipAssignedStrings": True, + "skipUntranslatedStrings": 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) + + @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, + "skipUntranslatedStrings": 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, + "skipUntranslatedStrings": 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, + "skipUntranslatedStrings": 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.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", + ( + ( + { + "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.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.add_vendor_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", + "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.add_vendor_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, + "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_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]] From e91d9928fb545758a151e2ba469db14e358983e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Chr=C3=A1stek?= Date: Mon, 2 Dec 2024 13:28:07 +0100 Subject: [PATCH 4/6] Fix typo in type for fileIds in add_language_service_task --- crowdin_api/api_resources/tasks/resource.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crowdin_api/api_resources/tasks/resource.py b/crowdin_api/api_resources/tasks/resource.py index 84763c4..5d2a748 100644 --- a/crowdin_api/api_resources/tasks/resource.py +++ b/crowdin_api/api_resources/tasks/resource.py @@ -275,7 +275,7 @@ 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, From caee32059ada4cf542f8fc311b5eac9976bf2d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Chr=C3=A1stek?= Date: Mon, 2 Dec 2024 13:38:39 +0100 Subject: [PATCH 5/6] Add "by_string_ids" methods --- crowdin_api/api_resources/tasks/resource.py | 272 ++++++++++++ .../tasks/tests/test_tasks_resources.py | 420 ++++++++++++++++++ 2 files changed, 692 insertions(+) diff --git a/crowdin_api/api_resources/tasks/resource.py b/crowdin_api/api_resources/tasks/resource.py index 5d2a748..719047e 100644 --- a/crowdin_api/api_resources/tasks/resource.py +++ b/crowdin_api/api_resources/tasks/resource.py @@ -271,6 +271,55 @@ 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, + splitFiles: Optional[bool] = None, + skipAssignedStrings: Optional[bool] = None, + skipUntranslatedStrings: 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, + "splitFiles": splitFiles, + "skipAssignedStrings": skipAssignedStrings, + "skipUntranslatedStrings": skipUntranslatedStrings, + "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, + "assignees": assignees, + "deadline": deadline, + "startedAt": startedAt, + "dateFrom": dateFrom, + "dateTo": dateTo, + }, + ) + def add_language_service_task( self, title: str, @@ -317,6 +366,48 @@ def add_language_service_task( } ) + 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, + skipUntranslatedStrings: Optional[bool] = None, + includePreTranslatedStringsOnly: Optional[bool] = None, + includeUntranslatedStringsOnly: 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, + "skipUntranslatedStrings": skipUntranslatedStrings, + "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, + "includeUntranslatedStringsOnly": includeUntranslatedStringsOnly, + "dateFrom": dateFrom, + "dateTo": dateTo, + } + ) + def add_vendor_oht_task( self, title: str, @@ -365,6 +456,50 @@ def add_vendor_oht_task( }, ) + 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, + skipUntranslatedStrings: Optional[bool] = None, + includePreTranslatedStringsOnly: Optional[bool] = None, + includeUntranslatedStringsOnly: 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, + "skipUntranslatedStrings": skipUntranslatedStrings, + "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, + "includeUntranslatedStringsOnly": includeUntranslatedStringsOnly, + "dateFrom": dateFrom, + "dateTo": dateTo, + "vendor": "oht", + }, + ) + def add_vendor_gengo_task( self, title: str, @@ -417,6 +552,54 @@ def add_vendor_gengo_task( }, ) + def add_vendor_gengo_by_string_ids_task( + self, + title: str, + languageId: str, + stringIds: Iterable[int], + type: GengoCrowdinTaskType, + 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": type, + "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, @@ -461,6 +644,46 @@ def add_vendor_translated_task( }, ) + def add_vendor_translated_by_string_ids_task( + self, + title: str, + languageId: str, + stringIds: Iterable[int], + type: TranslatedCrowdinTaskType, + 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": type, + "status": status, + "description": description, + "expertise": expertise, + "subject": subject, + "dateFrom": dateFrom, + "dateTo": dateTo, + "vendor": "translated", + }, + ) + def add_vendor_manual_task( self, title: str, @@ -514,6 +737,55 @@ 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, + skipUntranslatedStrings: 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, + "skipUntranslatedStrings": skipUntranslatedStrings, + "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, + "assignees": assignees, + "deadline": deadline, + "startedAt": startedAt, + "dateFrom": dateFrom, + "dateTo": dateTo, + }, + ) + def add_pending_task( self, title: str, 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 3c151a0..54ed168 100644 --- a/crowdin_api/api_resources/tasks/tests/test_tasks_resources.py +++ b/crowdin_api/api_resources/tasks/tests/test_tasks_resources.py @@ -275,6 +275,80 @@ 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, + "splitFiles": None, + "skipAssignedStrings": None, + "skipUntranslatedStrings": 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", + "splitFiles": False, + "skipAssignedStrings": False, + "skipUntranslatedStrings": 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", + "splitFiles": False, + "skipAssignedStrings": False, + "skipUntranslatedStrings": 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", ( @@ -347,6 +421,72 @@ 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, + "skipUntranslatedStrings": None, + "includePreTranslatedStringsOnly": None, + "includeUntranslatedStringsOnly": None, + "dateFrom": None, + "dateTo": None, + }, + ), + ( + { + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": LanguageServiceTaskType.TRANSLATE_BY_VENDOR, + "status": CrowdinTaskStatus.TODO, + "description": "description", + "skipUntranslatedStrings": False, + "includePreTranslatedStringsOnly": False, + "includeUntranslatedStringsOnly": 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", + "skipUntranslatedStrings": False, + "includePreTranslatedStringsOnly": False, + "includeUntranslatedStringsOnly": 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", ( @@ -420,6 +560,73 @@ 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, + "expertise": None, + "skipUntranslatedStrings": None, + "includePreTranslatedStringsOnly": None, + "includeUntranslatedStringsOnly": 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, + "skipUntranslatedStrings": False, + "includePreTranslatedStringsOnly": False, + "includeUntranslatedStringsOnly": 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, + "skipUntranslatedStrings": False, + "includePreTranslatedStringsOnly": False, + "includeUntranslatedStringsOnly": 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", ( @@ -499,6 +706,79 @@ def test_add_vendor_gengo_task(self, m_add_task, incoming_data, request_data, ba assert resource.add_vendor_gengo_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": GengoCrowdinTaskType.TRANSLATE_BY_VENDOR, + }, + { + "vendor": "gengo", + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": GengoCrowdinTaskType.TRANSLATE_BY_VENDOR, + "status": None, + "description": None, + "expertise": None, + "tone": None, + "purpose": None, + "customerMessage": None, + "usePreferred": None, + "editService": None, + "dateFrom": None, + "dateTo": None, + }, + ), + ( + { + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": GengoCrowdinTaskType.TRANSLATE_BY_VENDOR, + "status": CrowdinTaskStatus.IN_PROGRESS, + "description": "description", + "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), + }, + { + "vendor": "gengo", + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": GengoCrowdinTaskType.TRANSLATE_BY_VENDOR, + "status": CrowdinTaskStatus.IN_PROGRESS, + "description": "description", + "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), + }, + ), + ), + ) + @mock.patch("crowdin_api.api_resources.tasks.resource.TasksResource.add_task") + 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_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( "incoming_data, request_data", ( @@ -568,6 +848,69 @@ def test_add_vendor_translated_task( 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], + "type": TranslatedCrowdinTaskType.TRANSLATE_BY_VENDOR, + }, + { + "vendor": "translated", + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": TranslatedCrowdinTaskType.TRANSLATE_BY_VENDOR, + "status": None, + "description": None, + "expertise": None, + "subject": None, + "dateFrom": None, + "dateTo": None, + }, + ), + ( + { + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": TranslatedCrowdinTaskType.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), + }, + { + "vendor": "translated", + "title": "title", + "languageId": "ua", + "stringIds": [1, 2, 3], + "type": TranslatedCrowdinTaskType.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", ( @@ -651,6 +994,83 @@ 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, + "skipUntranslatedStrings": 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, + "skipUntranslatedStrings": 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, + "skipUntranslatedStrings": 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", ( From f7b5f95308e674d97e6ef8bd226473fd972b3391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Chr=C3=A1stek?= Date: Mon, 2 Dec 2024 14:33:42 +0100 Subject: [PATCH 6/6] Remove deprecated parameters --- crowdin_api/api_resources/tasks/enums.py | 8 -- crowdin_api/api_resources/tasks/resource.py | 56 +++--------- .../tasks/tests/test_tasks_resources.py | 91 +++++-------------- 3 files changed, 36 insertions(+), 119 deletions(-) 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 719047e..677e437 100644 --- a/crowdin_api/api_resources/tasks/resource.py +++ b/crowdin_api/api_resources/tasks/resource.py @@ -10,12 +10,10 @@ GengoCrowdinTaskExpertise, GengoCrowdinTaskPurpose, GengoCrowdinTaskTone, - GengoCrowdinTaskType, OhtCrowdinTaskExpertise, OhtCrowdinTaskType, TranslatedCrowdinTaskExpertise, TranslatedCrowdinTaskSubjects, - TranslatedCrowdinTaskType, ManualCrowdinTaskType, ManualCrowdinVendors, ) @@ -227,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, @@ -257,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, @@ -280,9 +276,8 @@ def add_general_by_string_ids_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, assignees: Optional[Iterable[CrowdinTaskAssignee]] = None, deadline: Optional[datetime] = None, @@ -308,9 +303,8 @@ def add_general_by_string_ids_task( "type": type, "status": status, "description": description, - "splitFiles": splitFiles, + "splitContent": splitContent, "skipAssignedStrings": skipAssignedStrings, - "skipUntranslatedStrings": skipUntranslatedStrings, "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, "assignees": assignees, "deadline": deadline, @@ -331,9 +325,7 @@ def add_language_service_task( 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, ): @@ -358,9 +350,7 @@ def add_language_service_task( "description": description, "labelIds": labelIds, "excludeLabelIds": excludeLabelIds, - "skipUntranslatedStrings": skipUntranslatedStrings, "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, - "includeUntranslatedStringsOnly": includeUntranslatedStringsOnly, "dateFrom": dateFrom, "dateTo": dateTo, } @@ -375,9 +365,7 @@ def add_language_service_by_string_ids_task( projectId: Optional[int] = None, status: Optional[CrowdinTaskStatus] = None, description: Optional[str] = None, - skipUntranslatedStrings: Optional[bool] = None, includePreTranslatedStringsOnly: Optional[bool] = None, - includeUntranslatedStringsOnly: Optional[bool] = None, dateFrom: Optional[datetime] = None, dateTo: Optional[datetime] = None, ): @@ -400,9 +388,7 @@ def add_language_service_by_string_ids_task( "vendor": "crowdin_language_service", "status": status, "description": description, - "skipUntranslatedStrings": skipUntranslatedStrings, "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, - "includeUntranslatedStringsOnly": includeUntranslatedStringsOnly, "dateFrom": dateFrom, "dateTo": dateTo, } @@ -418,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, ): @@ -445,11 +430,10 @@ 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", @@ -466,9 +450,8 @@ def add_vendor_oht_by_string_ids_task( status: Optional[CrowdinTaskStatus] = None, description: Optional[str] = None, expertise: Optional[OhtCrowdinTaskExpertise] = None, - skipUntranslatedStrings: Optional[bool] = None, + editService: Optional[bool] = None, includePreTranslatedStringsOnly: Optional[bool] = None, - includeUntranslatedStringsOnly: Optional[bool] = None, dateFrom: Optional[datetime] = None, dateTo: Optional[datetime] = None, ): @@ -491,9 +474,8 @@ def add_vendor_oht_by_string_ids_task( "status": status, "description": description, "expertise": expertise, - "skipUntranslatedStrings": skipUntranslatedStrings, + "editService": editService, "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, - "includeUntranslatedStringsOnly": includeUntranslatedStringsOnly, "dateFrom": dateFrom, "dateTo": dateTo, "vendor": "oht", @@ -505,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, @@ -535,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, @@ -557,7 +538,6 @@ def add_vendor_gengo_by_string_ids_task( title: str, languageId: str, stringIds: Iterable[int], - type: GengoCrowdinTaskType, projectId: Optional[int] = None, status: Optional[CrowdinTaskStatus] = None, description: Optional[str] = None, @@ -585,7 +565,7 @@ def add_vendor_gengo_by_string_ids_task( "title": title, "languageId": languageId, "stringIds": stringIds, - "type": type, + "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, "status": status, "description": description, "expertise": expertise, @@ -605,7 +585,6 @@ def add_vendor_translated_task( title: str, languageId: str, fileIds: Iterable[int], - type: TranslatedCrowdinTaskType, projectId: Optional[int] = None, status: Optional[CrowdinTaskStatus] = None, description: Optional[str] = None, @@ -631,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, @@ -649,7 +628,6 @@ def add_vendor_translated_by_string_ids_task( title: str, languageId: str, stringIds: Iterable[int], - type: TranslatedCrowdinTaskType, projectId: Optional[int] = None, status: Optional[CrowdinTaskStatus] = None, description: Optional[str] = None, @@ -673,7 +651,7 @@ def add_vendor_translated_by_string_ids_task( "title": title, "languageId": languageId, "stringIds": stringIds, - "type": type, + "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, "status": status, "description": description, "expertise": expertise, @@ -695,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, @@ -725,7 +702,6 @@ def add_vendor_manual_task( "status": status, "description": description, "skipAssignedStrings": skipAssignedStrings, - "skipUntranslatedStrings": skipUntranslatedStrings, "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, "labelIds": labelIds, "excludeLabelIds": excludeLabelIds, @@ -748,7 +724,6 @@ def add_vendor_manual_by_string_ids_task( status: Optional[CrowdinTaskStatus] = None, description: Optional[str] = None, skipAssignedStrings: Optional[bool] = None, - skipUntranslatedStrings: Optional[bool] = None, includePreTranslatedStringsOnly: Optional[bool] = None, assignees: Optional[Iterable[CrowdinTaskAssignee]] = None, deadline: Optional[datetime] = None, @@ -776,7 +751,6 @@ def add_vendor_manual_by_string_ids_task( "status": status, "description": description, "skipAssignedStrings": skipAssignedStrings, - "skipUntranslatedStrings": skipUntranslatedStrings, "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, "assignees": assignees, "deadline": deadline, @@ -1017,14 +991,13 @@ def add_general_task( title: str, languageId: str, fileIds: Iterable[int], - type: Optional[CrowdinGeneralTaskType] = None, + 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, - skipUntranslatedStrings: Optional[bool] = None, includePreTranslatedStringsOnly: Optional[bool] = None, labelIds: Optional[Iterable[int]] = None, excludeLabelIds: Optional[Iterable[int]] = None, @@ -1056,7 +1029,6 @@ def add_general_task( "description": description, "splitContent": splitContent, "skipAssignedStrings": skipAssignedStrings, - "skipUntranslatedStrings": skipUntranslatedStrings, "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, "labelIds": labelIds, "excludeLabelIds": excludeLabelIds, @@ -1081,7 +1053,6 @@ def add_general_by_string_ids_task( description: Optional[str] = None, splitContent: Optional[bool] = None, skipAssignedStrings: Optional[bool] = None, - skipUntranslatedStrings: Optional[bool] = None, includePreTranslatedStringsOnly: Optional[bool] = None, assignees: Optional[Iterable[CrowdinTaskAssignee]] = None, assignedTeams: Optional[Iterable[EnterpriseTaskAssignedTeams]] = None, @@ -1111,7 +1082,6 @@ def add_general_by_string_ids_task( "description": description, "splitContent": splitContent, "skipAssignedStrings": skipAssignedStrings, - "skipUntranslatedStrings": skipUntranslatedStrings, "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, "assignees": assignees, "assignedTeams": assignedTeams, 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 54ed168..eddcb3c 100644 --- a/crowdin_api/api_resources/tasks/tests/test_tasks_resources.py +++ b/crowdin_api/api_resources/tasks/tests/test_tasks_resources.py @@ -10,13 +10,11 @@ GengoCrowdinTaskExpertise, GengoCrowdinTaskPurpose, GengoCrowdinTaskTone, - GengoCrowdinTaskType, OhtCrowdinTaskExpertise, OhtCrowdinTaskType, TaskOperationPatchPath, TranslatedCrowdinTaskExpertise, TranslatedCrowdinTaskSubjects, - TranslatedCrowdinTaskType, ConfigTaskOperationPatchPath, LanguageServiceTaskType, ManualCrowdinTaskType, @@ -212,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, @@ -233,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], @@ -252,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], @@ -292,9 +287,8 @@ def test_add_general_task(self, m_add_task, incoming_data, request_data, base_ab "type": CrowdinGeneralTaskType.TRANSLATE, "status": None, "description": None, - "splitFiles": None, + "splitContent": None, "skipAssignedStrings": None, - "skipUntranslatedStrings": None, "includePreTranslatedStringsOnly": None, "assignees": None, "deadline": None, @@ -311,9 +305,8 @@ def test_add_general_task(self, m_add_task, incoming_data, request_data, base_ab "type": CrowdinGeneralTaskType.TRANSLATE, "status": CrowdinTaskStatus.TODO, "description": "description", - "splitFiles": False, + "splitContent": False, "skipAssignedStrings": False, - "skipUntranslatedStrings": False, "includePreTranslatedStringsOnly": False, "assignees": [{"id": 1, "wordsCount": 2}], "deadline": datetime(year=1988, month=9, day=26), @@ -328,9 +321,8 @@ def test_add_general_task(self, m_add_task, incoming_data, request_data, base_ab "type": CrowdinGeneralTaskType.TRANSLATE, "status": CrowdinTaskStatus.TODO, "description": "description", - "splitFiles": False, + "splitContent": False, "skipAssignedStrings": False, - "skipUntranslatedStrings": False, "includePreTranslatedStringsOnly": False, "assignees": [{"id": 1, "wordsCount": 2}], "deadline": datetime(year=1988, month=9, day=26), @@ -369,9 +361,7 @@ def test_add_general_by_string_ids_task(self, m_add_task, incoming_data, request "description": None, "labelIds": None, "excludeLabelIds": None, - "skipUntranslatedStrings": None, "includePreTranslatedStringsOnly": None, - "includeUntranslatedStringsOnly": None, "dateFrom": None, "dateTo": None, }, @@ -386,9 +376,7 @@ def test_add_general_by_string_ids_task(self, m_add_task, incoming_data, request "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), }, @@ -402,9 +390,7 @@ def test_add_general_by_string_ids_task(self, m_add_task, incoming_data, request "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), }, @@ -439,9 +425,7 @@ def test_add_language_service_task( "vendor": "crowdin_language_service", "status": None, "description": None, - "skipUntranslatedStrings": None, "includePreTranslatedStringsOnly": None, - "includeUntranslatedStringsOnly": None, "dateFrom": None, "dateTo": None, }, @@ -454,9 +438,7 @@ def test_add_language_service_task( "type": LanguageServiceTaskType.TRANSLATE_BY_VENDOR, "status": CrowdinTaskStatus.TODO, "description": "description", - "skipUntranslatedStrings": False, "includePreTranslatedStringsOnly": False, - "includeUntranslatedStringsOnly": False, "dateFrom": datetime(year=1988, month=1, day=4), "dateTo": datetime(year=2015, month=10, day=13), }, @@ -468,9 +450,7 @@ def test_add_language_service_task( "vendor": "crowdin_language_service", "status": CrowdinTaskStatus.TODO, "description": "description", - "skipUntranslatedStrings": False, "includePreTranslatedStringsOnly": False, - "includeUntranslatedStringsOnly": False, "dateFrom": datetime(year=1988, month=1, day=4), "dateTo": datetime(year=2015, month=10, day=13), }, @@ -506,11 +486,10 @@ def test_add_language_service_by_string_ids_task( "status": None, "description": None, "expertise": None, + "editService": None, "labelIds": None, "excludeLabelIds": None, - "skipUntranslatedStrings": None, "includePreTranslatedStringsOnly": None, - "includeUntranslatedStringsOnly": None, "dateFrom": None, "dateTo": None, }, @@ -524,11 +503,10 @@ def test_add_language_service_by_string_ids_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), }, @@ -541,11 +519,10 @@ def test_add_language_service_by_string_ids_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), }, @@ -578,10 +555,9 @@ def test_add_vendor_oht_task(self, m_add_task, incoming_data, request_data, base "type": OhtCrowdinTaskType.TRANSLATE_BY_VENDOR, "status": None, "description": None, + "editService": None, "expertise": None, - "skipUntranslatedStrings": None, "includePreTranslatedStringsOnly": None, - "includeUntranslatedStringsOnly": None, "dateFrom": None, "dateTo": None, }, @@ -595,9 +571,8 @@ def test_add_vendor_oht_task(self, m_add_task, incoming_data, request_data, base "status": CrowdinTaskStatus.TODO, "description": "description", "expertise": OhtCrowdinTaskExpertise.AD_WORDS_BANNERS, - "skipUntranslatedStrings": False, + "editService": True, "includePreTranslatedStringsOnly": False, - "includeUntranslatedStringsOnly": False, "dateFrom": datetime(year=1988, month=1, day=4), "dateTo": datetime(year=2015, month=10, day=13), }, @@ -610,9 +585,8 @@ def test_add_vendor_oht_task(self, m_add_task, incoming_data, request_data, base "status": CrowdinTaskStatus.TODO, "description": "description", "expertise": OhtCrowdinTaskExpertise.AD_WORDS_BANNERS, - "skipUntranslatedStrings": False, + "editService": True, "includePreTranslatedStringsOnly": False, - "includeUntranslatedStringsOnly": False, "dateFrom": datetime(year=1988, month=1, day=4), "dateTo": datetime(year=2015, month=10, day=13), }, @@ -635,14 +609,13 @@ def test_add_vendor_oht_by_string_ids_task(self, m_add_task, incoming_data, requ "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, @@ -662,7 +635,6 @@ def test_add_vendor_oht_by_string_ids_task(self, m_add_task, incoming_data, requ "title": "title", "languageId": "ua", "fileIds": [1, 2, 3], - "type": GengoCrowdinTaskType.TRANSLATE_BY_VENDOR, "status": CrowdinTaskStatus.IN_PROGRESS, "description": "description", "expertise": GengoCrowdinTaskExpertise.PRO, @@ -681,7 +653,7 @@ def test_add_vendor_oht_by_string_ids_task(self, m_add_task, incoming_data, requ "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, @@ -714,22 +686,21 @@ def test_add_vendor_gengo_task(self, m_add_task, incoming_data, request_data, ba "title": "title", "languageId": "ua", "stringIds": [1, 2, 3], - "type": GengoCrowdinTaskType.TRANSLATE_BY_VENDOR, }, { "vendor": "gengo", "title": "title", "languageId": "ua", "stringIds": [1, 2, 3], - "type": GengoCrowdinTaskType.TRANSLATE_BY_VENDOR, + "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, "status": None, "description": None, "expertise": None, + "editService": None, "tone": None, "purpose": None, "customerMessage": None, "usePreferred": None, - "editService": None, "dateFrom": None, "dateTo": None, }, @@ -739,7 +710,6 @@ def test_add_vendor_gengo_task(self, m_add_task, incoming_data, request_data, ba "title": "title", "languageId": "ua", "stringIds": [1, 2, 3], - "type": GengoCrowdinTaskType.TRANSLATE_BY_VENDOR, "status": CrowdinTaskStatus.IN_PROGRESS, "description": "description", "expertise": GengoCrowdinTaskExpertise.PRO, @@ -756,7 +726,7 @@ def test_add_vendor_gengo_task(self, m_add_task, incoming_data, request_data, ba "title": "title", "languageId": "ua", "stringIds": [1, 2, 3], - "type": GengoCrowdinTaskType.TRANSLATE_BY_VENDOR, + "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, "status": CrowdinTaskStatus.IN_PROGRESS, "description": "description", "expertise": GengoCrowdinTaskExpertise.PRO, @@ -787,14 +757,13 @@ def test_add_vendor_gengo_by_string_ids_task(self, m_add_task, incoming_data, re "title": "title", "languageId": "ua", "fileIds": [1, 2, 3], - "type": TranslatedCrowdinTaskType.TRANSLATE_BY_VENDOR, }, { "vendor": "translated", "title": "title", "languageId": "ua", "fileIds": [1, 2, 3], - "type": TranslatedCrowdinTaskType.TRANSLATE_BY_VENDOR, + "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, "status": None, "description": None, "expertise": None, @@ -810,7 +779,6 @@ def test_add_vendor_gengo_by_string_ids_task(self, m_add_task, incoming_data, re "title": "title", "languageId": "ua", "fileIds": [1, 2, 3], - "type": TranslatedCrowdinTaskType.TRANSLATE_BY_VENDOR, "status": CrowdinTaskStatus.IN_PROGRESS, "description": "description", "expertise": TranslatedCrowdinTaskExpertise.ECONOMY, @@ -825,7 +793,7 @@ def test_add_vendor_gengo_by_string_ids_task(self, m_add_task, incoming_data, re "title": "title", "languageId": "ua", "fileIds": [1, 2, 3], - "type": TranslatedCrowdinTaskType.TRANSLATE_BY_VENDOR, + "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, "status": CrowdinTaskStatus.IN_PROGRESS, "description": "description", "expertise": TranslatedCrowdinTaskExpertise.ECONOMY, @@ -856,14 +824,13 @@ def test_add_vendor_translated_task( "title": "title", "languageId": "ua", "stringIds": [1, 2, 3], - "type": TranslatedCrowdinTaskType.TRANSLATE_BY_VENDOR, }, { "vendor": "translated", "title": "title", "languageId": "ua", "stringIds": [1, 2, 3], - "type": TranslatedCrowdinTaskType.TRANSLATE_BY_VENDOR, + "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, "status": None, "description": None, "expertise": None, @@ -877,7 +844,6 @@ def test_add_vendor_translated_task( "title": "title", "languageId": "ua", "stringIds": [1, 2, 3], - "type": TranslatedCrowdinTaskType.TRANSLATE_BY_VENDOR, "status": CrowdinTaskStatus.IN_PROGRESS, "description": "description", "expertise": TranslatedCrowdinTaskExpertise.ECONOMY, @@ -890,7 +856,7 @@ def test_add_vendor_translated_task( "title": "title", "languageId": "ua", "stringIds": [1, 2, 3], - "type": TranslatedCrowdinTaskType.TRANSLATE_BY_VENDOR, + "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, "status": CrowdinTaskStatus.IN_PROGRESS, "description": "description", "expertise": TranslatedCrowdinTaskExpertise.ECONOMY, @@ -931,7 +897,6 @@ def test_add_vendor_translated_by_string_ids_task( "status": None, "description": None, "skipAssignedStrings": None, - "skipUntranslatedStrings": None, "includePreTranslatedStringsOnly": None, "labelIds": None, "excludeLabelIds": None, @@ -952,7 +917,6 @@ def test_add_vendor_translated_by_string_ids_task( "status": CrowdinTaskStatus.TODO, "description": "description", "skipAssignedStrings": False, - "skipUntranslatedStrings": False, "includePreTranslatedStringsOnly": False, "labelIds": [1, 2, 3], "excludeLabelIds": [4, 5, 6], @@ -971,7 +935,6 @@ def test_add_vendor_translated_by_string_ids_task( "status": CrowdinTaskStatus.TODO, "description": "description", "skipAssignedStrings": False, - "skipUntranslatedStrings": False, "includePreTranslatedStringsOnly": False, "labelIds": [1, 2, 3], "excludeLabelIds": [4, 5, 6], @@ -1014,7 +977,6 @@ def test_add_vendor_manual_task( "status": None, "description": None, "skipAssignedStrings": None, - "skipUntranslatedStrings": None, "includePreTranslatedStringsOnly": None, "assignees": None, "deadline": None, @@ -1033,7 +995,6 @@ def test_add_vendor_manual_task( "status": CrowdinTaskStatus.TODO, "description": "description", "skipAssignedStrings": False, - "skipUntranslatedStrings": False, "includePreTranslatedStringsOnly": False, "assignees": [{"id": 1, "wordsCount": 2}], "deadline": datetime(year=1988, month=9, day=26), @@ -1050,7 +1011,6 @@ def test_add_vendor_manual_task( "status": CrowdinTaskStatus.TODO, "description": "description", "skipAssignedStrings": False, - "skipUntranslatedStrings": False, "includePreTranslatedStringsOnly": False, "assignees": [{"id": 1, "wordsCount": 2}], "deadline": datetime(year=1988, month=9, day=26), @@ -1357,7 +1317,6 @@ def test_add_task_settings_template(self, m_request, base_absolut_url): "description": None, "splitContent": None, "skipAssignedStrings": None, - "skipUntranslatedStrings": None, "includePreTranslatedStringsOnly": None, "labelIds": None, "excludeLabelIds": None, @@ -1375,11 +1334,11 @@ def test_add_task_settings_template(self, m_request, base_absolut_url): "languageId": "ua", "fileIds": [1, 2, 3], "workflowStepId": 1, + "type": CrowdinGeneralTaskType.TRANSLATE, "status": CrowdinTaskStatus.TODO, "description": "description", "splitContent": True, "skipAssignedStrings": True, - "skipUntranslatedStrings": True, "includePreTranslatedStringsOnly": True, "labelIds": [1, 2, 3], "excludeLabelIds": [4, 5, 6], @@ -1394,13 +1353,12 @@ def test_add_task_settings_template(self, m_request, base_absolut_url): "title": "title", "languageId": "ua", "fileIds": [1, 2, 3], - "type": None, + "type": CrowdinGeneralTaskType.TRANSLATE, "workflowStepId": 1, "status": CrowdinTaskStatus.TODO, "description": "description", "splitContent": True, "skipAssignedStrings": True, - "skipUntranslatedStrings": True, "includePreTranslatedStringsOnly": True, "labelIds": [1, 2, 3], "excludeLabelIds": [4, 5, 6], @@ -1446,7 +1404,6 @@ def test_add_general_task( "description": None, "splitContent": None, "skipAssignedStrings": None, - "skipUntranslatedStrings": None, "includePreTranslatedStringsOnly": None, "assignees": None, "assignedTeams": None, @@ -1466,7 +1423,6 @@ def test_add_general_task( "description": "description", "splitContent": True, "skipAssignedStrings": True, - "skipUntranslatedStrings": True, "includePreTranslatedStringsOnly": True, "assignees": [{"id": 1, "wordsCount": 2}], "assignedTeams": [{"id": 1, "wordsCount": 2}], @@ -1485,7 +1441,6 @@ def test_add_general_task( "description": "description", "splitContent": True, "skipAssignedStrings": True, - "skipUntranslatedStrings": True, "includePreTranslatedStringsOnly": True, "assignees": [{"id": 1, "wordsCount": 2}], "assignedTeams": [{"id": 1, "wordsCount": 2}],