diff --git a/crowdin_api/api_resources/tasks/enums.py b/crowdin_api/api_resources/tasks/enums.py index 1ba8c25..dbf8f6e 100644 --- a/crowdin_api/api_resources/tasks/enums.py +++ b/crowdin_api/api_resources/tasks/enums.py @@ -12,6 +12,8 @@ class TaskOperationPatchPath(Enum): DATE_FROM = "/dateFrom" DATE_TO = "/dateTo" LABEL_IDS = "/labelIds" + BATCH_ID = "/batchId" + RESET_SCOPE = "/resetScope" class VendorTaskOperationPatchPath(Enum): @@ -44,137 +46,6 @@ class CrowdinTaskStatus(Enum): CLOSED = "closed" -# Language Service -class LanguageServiceTaskType(Enum): - TRANSLATE_BY_VENDOR = 2 - PROOFREAD_BY_VENDOR = 3 - - -# Oht -class OhtCrowdinTaskType(Enum): - TRANSLATE_BY_VENDOR = 2 - PROOFREAD_BY_VENDOR = 3 - - -class OhtCrowdinTaskExpertise(Enum): - STANDARD = "standard" - MOBILE_APPLICATIONS = "mobile-applications" - SOFTWARE_IT = "software-it" - GAMING_VIDEO_GAMES = "gaming-video-games" - TECHNICAL_ENGINEERING = "technical-engineering" - MARKETING_CONSUMER_MEDIA = "marketing-consumer-media" - BUSINESS_FINANCE = "business-finance" - LEGAL_CERTIFICATE = "legal-certificate" - CV = "cv" - MEDICAL = "medical" - PATENTS = "patents" - AD_WORDS_BANNERS = "ad-words-banners" - AUTOMOTIVE_AEROSPACE = "automotive-aerospace" - SCIENTIFIC = "scientific" - SCIENTIFIC_ACADEMIC = "scientific-academic" - TOURISM = "tourism" - CERTIFICATES_TRANSLATION = "certificates-translation" - TRAINING_EMPLOYEE_HANDBOOKS = "training-employee-handbooks" - FOREX_CRYPTO = "forex-crypto" - - -# Gengo -class GengoCrowdinTaskExpertise(Enum): - STANDARD = "standard" - PRO = "pro" - - -class GengoCrowdinTaskTone(Enum): - EMPTY = "" - INFORMAL = "Informal" - FRIENDLY = "Friendly" - BUSINESS = "Business" - FORMAL = "Formal" - OTHER = "other" - - -class GengoCrowdinTaskPurpose(Enum): - STANDARD = "standard" - PERSONAL_USE = "Personal use" - BUSINESS = "Business" - ONLINE_CONTENT = "Online content" - APP_OR_WEB_LOCALIZATION = "App/Web localization" - MEDIA_CONTENT = "Media content" - SEMI_TECHNICAL = "Semi-technical" - OTHER = "other" - - -# Translated -class TranslatedCrowdinTaskExpertise(Enum): - ECONOMY = "P" - PROFESSIONAL = "T" - PREMIUM = "R" - - -class TranslatedCrowdinTaskSubjects(Enum): - GENERAL = "general" - ACCOUNTING_FINANCE = "accounting_finance" - AEROSPACE_DEFENCE = "aerospace_defence" - ARCHITECTURE = "architecture" - ART = "art" - AUTOMOTIVE = "automotive" - CERTIFICATES_DIPLOMAS_LICENCES_CV_ETC = "certificates_diplomas_licences_cv_etc" - CHEMICAL = "chemical" - CIVIL_ENGINEERING_CONSTRUCTION = "civil_engineering_construction" - CORPORATE_SOCIAL_RESPONSIBILITY = "corporate_social_responsibility" - COSMETICS = "cosmetics" - CULINARY = "culinary" - ELECTRONICS_ELECTRICAL_ENGINEERING = "electronics_electrical_engineering" - ENERGY_POWER_GENERATION_OIL_GAS = "energy_power_generation_oil_gas" - ENVIRONMENT = "environment" - FASHION = "fashion" - GAMES_VISEOGAMES_CASINO = "games_viseogames_casino" - GENERAL_BUSINESS_COMMERCE = "general_business_commerce" - HISTORY_ARCHAEOLOGY = "history_archaeology" - INFORMATION_TECHNOLOGY = "information_technology" - INSURANCE = "insurance" - INTERNET_ECOMMERCE = "internet_e-commerce" - LEGAL_DOCUMENTS_CONTRACTS = "legal_documents_contracts" - LITERARY_TRANSLATIONS = "literary_translations" - MARKETING_ADVERTISING_MATERIAL_PUBLIC_RELATIONS = ( - "marketing_advertising_material_public_relations" - ) - MATEMATICS_AND_PHYSICS = "matematics_and_physics" - MECHANICAL_MANUFACTURING = "mechanical_manufacturing" - MEDIA_JOURNALISM_PUBLISHING = "media_journalism_publishing" - MEDICAL_PHARMACEUTICAL = "medical_pharmaceutical" - MUSIC = "music" - PRIVATE_CORRESPONDENCE_LETTERS = "private_correspondence_letters" - RELIGION = "religion" - SCIENCE = "science" - SHIPPING_SAILING_MARITIME = "shipping_sailing_maritime" - SOCIAL_SCIENCE = "social_science" - TELECOMMUNICATIONS = "telecommunications" - TRAVEL_TOURISM = "travel_tourism" - - -# Manual -class ManualCrowdinTaskType(Enum): - TRANSLATE_BY_VENDOR = 2 - PROOFREAD_BY_VENDOR = 3 - - -class ManualCrowdinVendors(Enum): - ALCONOST = "alconost" - BABBLE_ON = "babbleon" - TOMEDES = "tomedes" - E2F = "e2f" - WRITE_PATH = "write_path_admin" - INLINGO = "inlingo" - ACCLARO = "acclaro" - TRANSLATE_BY_HUMANS = "translate_by_humans" - LINGO24 = "lingo24" - ASSERTIO_LANGUAGE_SERVICE = "assertio_language_services" - GTE_LOCALIZE = "gte_localize" - KETTU_SOLUTIONS = "kettu_solutions" - LANGUAGELINE_TRANSLATION_SOLUTIONS = "languageline_solutions" - - class ListTasksOrderBy(Enum): ID = "id" TYPE = "type" diff --git a/crowdin_api/api_resources/tasks/resource.py b/crowdin_api/api_resources/tasks/resource.py index 6ebef30..05732e7 100644 --- a/crowdin_api/api_resources/tasks/resource.py +++ b/crowdin_api/api_resources/tasks/resource.py @@ -6,16 +6,6 @@ CrowdinGeneralTaskType, CrowdinTaskStatus, CrowdinTaskType, - LanguageServiceTaskType, - GengoCrowdinTaskExpertise, - GengoCrowdinTaskPurpose, - GengoCrowdinTaskTone, - OhtCrowdinTaskExpertise, - OhtCrowdinTaskType, - TranslatedCrowdinTaskExpertise, - TranslatedCrowdinTaskSubjects, - ManualCrowdinTaskType, - ManualCrowdinVendors, ) from crowdin_api.api_resources.tasks.types import ( CrowdinTaskAssignee, @@ -182,6 +172,7 @@ def list_tasks( orderBy: Optional[Sorting] = None, assigneeId: Optional[int] = None, status: Optional[CrowdinTaskStatus] = None, + batchId: Optional[int] = None, page: Optional[int] = None, offset: Optional[int] = None, limit: Optional[int] = None, @@ -191,10 +182,18 @@ def list_tasks( Link to documentation: https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.getMany + + Link to documentation for enterprise: + https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.tasks.getMany """ projectId = projectId or self.get_project_id() - params = {"orderBy": orderBy, "assigneeId": assigneeId, "status": status} + params = { + "orderBy": orderBy, + "assigneeId": assigneeId, + "status": status, + "batchId": batchId, + } params.update(self.get_page_params(page=page, offset=offset, limit=limit)) return self._get_entire_data( @@ -238,6 +237,7 @@ def add_general_task( startedAt: Optional[datetime] = None, dateFrom: Optional[datetime] = None, dateTo: Optional[datetime] = None, + batchId: Optional[int] = None, ): """ Add Task(Crowdin Task Create Form). @@ -267,6 +267,7 @@ def add_general_task( "startedAt": startedAt, "dateFrom": dateFrom, "dateTo": dateTo, + "batchId": batchId, }, ) @@ -287,6 +288,7 @@ def add_general_by_string_ids_task( startedAt: Optional[datetime] = None, dateFrom: Optional[datetime] = None, dateTo: Optional[datetime] = None, + batchId: Optional[int] = None, ): """ Add Task(Crowdin Task Create Form). @@ -314,364 +316,17 @@ def add_general_by_string_ids_task( "startedAt": startedAt, "dateFrom": dateFrom, "dateTo": dateTo, + "batchId": batchId, }, ) - def add_language_service_task( - self, - title: str, - languageId: 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, - 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, - "fileIds": fileIds, - "type": type, - "vendor": "crowdin_language_service", - "status": status, - "description": description, - "labelIds": labelIds, - "excludeLabelIds": excludeLabelIds, - "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, - "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, - } - ) - - def add_vendor_oht_task( - self, - title: str, - languageId: str, - fileIds: Iterable[int], - type: OhtCrowdinTaskType, - projectId: Optional[int] = None, - 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, - 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, - "fileIds": fileIds, - "type": type, - "status": status, - "description": description, - "expertise": expertise, - "editService": editService, - "labelIds": labelIds, - "excludeLabelIds": excludeLabelIds, - "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, - "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", - }, - ) - - def add_vendor_gengo_task( - self, - title: str, - languageId: str, - fileIds: 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, - labelIds: Optional[Iterable[int]] = None, - excludeLabelIds: Optional[Iterable[int]] = 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, - "fileIds": fileIds, - "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, - "status": status, - "description": description, - "expertise": expertise, - "tone": tone, - "purpose": purpose, - "customerMessage": customerMessage, - "usePreferred": usePreferred, - "editService": editService, - "labelIds": labelIds, - "excludeLabelIds": excludeLabelIds, - "dateFrom": dateFrom, - "dateTo": dateTo, - "vendor": "gengo", - }, - ) - - 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], - projectId: Optional[int] = None, - status: Optional[CrowdinTaskStatus] = None, - description: Optional[str] = None, - expertise: Optional[TranslatedCrowdinTaskExpertise] = None, - subject: Optional[TranslatedCrowdinTaskSubjects] = None, - labelIds: Optional[Iterable[int]] = None, - excludeLabelIds: Optional[Iterable[int]] = 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, - "fileIds": fileIds, - "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, - "status": status, - "description": description, - "expertise": expertise, - "subject": subject, - "labelIds": labelIds, - "excludeLabelIds": excludeLabelIds, - "dateFrom": dateFrom, - "dateTo": dateTo, - "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", - }, - ) - - def add_vendor_manual_task( + def add_vendor_task( self, title: str, languageId: str, fileIds: Iterable[int], - type: ManualCrowdinTaskType, - vendor: ManualCrowdinVendors, + type: CrowdinTaskType, + vendor: str, projectId: Optional[int] = None, status: Optional[CrowdinTaskStatus] = None, description: Optional[str] = None, @@ -679,14 +334,12 @@ def add_vendor_manual_task( includePreTranslatedStringsOnly: Optional[bool] = None, labelIds: Optional[Iterable[int]] = None, excludeLabelIds: Optional[Iterable[int]] = 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). + Add Task(Crowdin Vendor Task Create Form). Link to documentation: https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.post @@ -708,34 +361,30 @@ def add_vendor_manual_task( "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, "labelIds": labelIds, "excludeLabelIds": excludeLabelIds, - "assignees": assignees, "deadline": deadline, - "startedAt": startedAt, "dateFrom": dateFrom, "dateTo": dateTo, }, ) - def add_vendor_manual_by_string_ids_task( + def add_vendor_by_string_ids_task( self, title: str, languageId: str, stringIds: Iterable[int], - type: ManualCrowdinTaskType, - vendor: ManualCrowdinVendors, + type: CrowdinTaskType, + vendor: str, 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). + Add Task(Crowdin Vendor Task Create Form). Link to documentation: https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.post @@ -755,9 +404,7 @@ def add_vendor_manual_by_string_ids_task( "description": description, "skipAssignedStrings": skipAssignedStrings, "includePreTranslatedStringsOnly": includePreTranslatedStringsOnly, - "assignees": assignees, "deadline": deadline, - "startedAt": startedAt, "dateFrom": dateFrom, "dateTo": dateTo, }, @@ -790,44 +437,18 @@ def add_pending_task( }, ) - 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( + def add_vendor_pending_task( self, title: str, precedingTaskId: int, - vendor: ManualCrowdinVendors, + vendor: str, 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). + Add Task(Crowdin Vendor Pending Task Create Form). """ projectId = projectId or self.get_project_id() @@ -836,7 +457,7 @@ def add_vendor_manual_pending_task( projectId=projectId, request_data={ "precedingTaskId": precedingTaskId, - "type": ManualCrowdinTaskType.PROOFREAD_BY_VENDOR, + "type": CrowdinTaskType.PROOFREAD_BY_VENDOR, "vendor": vendor, "title": title, "description": description, @@ -1138,6 +759,7 @@ def add_general_task( startedAt: Optional[datetime] = None, dateFrom: Optional[datetime] = None, dateTo: Optional[datetime] = None, + batchId: Optional[int] = None, ): """ Add Task(Enterprise Task Create Form). @@ -1169,6 +791,7 @@ def add_general_task( "startedAt": startedAt, "dateFrom": dateFrom, "dateTo": dateTo, + "batchId": batchId, }, ) @@ -1191,6 +814,7 @@ def add_general_by_string_ids_task( startedAt: Optional[datetime] = None, dateFrom: Optional[datetime] = None, dateTo: Optional[datetime] = None, + batchId: Optional[int] = None, ): """ Add Task(Enterprise Task Create Form). @@ -1220,6 +844,7 @@ def add_general_by_string_ids_task( "startedAt": startedAt, "dateFrom": dateFrom, "dateTo": dateTo, + "batchId": batchId, }, ) @@ -1238,6 +863,7 @@ def add_vendor_task( deadline: Optional[datetime] = None, startedAt: Optional[datetime] = None, dateTo: Optional[datetime] = None, + batchId: Optional[int] = None, ): """ Add Task(Enterprise Vendor Task Create Form). @@ -1263,6 +889,7 @@ def add_vendor_task( "deadline": deadline, "startedAt": startedAt, "dateTo": dateTo, + "batchId": batchId, }, ) @@ -1279,6 +906,7 @@ def add_vendor_by_string_ids_task( deadline: Optional[datetime] = None, startedAt: Optional[datetime] = None, dateTo: Optional[datetime] = None, + batchId: Optional[int] = None, ): """ Add Task(Enterprise Vendor Task Create Form). @@ -1302,6 +930,7 @@ def add_vendor_by_string_ids_task( "deadline": deadline, "startedAt": startedAt, "dateTo": dateTo, + "batchId": batchId, }, ) 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 0a47b46..77ea73f 100644 --- a/crowdin_api/api_resources/tasks/tests/test_tasks_resources.py +++ b/crowdin_api/api_resources/tasks/tests/test_tasks_resources.py @@ -7,20 +7,10 @@ CrowdinGeneralTaskType, CrowdinTaskStatus, CrowdinTaskType, - GengoCrowdinTaskExpertise, - GengoCrowdinTaskPurpose, - GengoCrowdinTaskTone, ListTasksOrderBy, ListUserTasksOrderBy, - OhtCrowdinTaskExpertise, - OhtCrowdinTaskType, TaskOperationPatchPath, - TranslatedCrowdinTaskExpertise, - TranslatedCrowdinTaskSubjects, ConfigTaskOperationPatchPath, - LanguageServiceTaskType, - ManualCrowdinTaskType, - ManualCrowdinVendors, ) from crowdin_api.api_resources.tasks.resource import TasksResource, EnterpriseTasksResource from crowdin_api.requester import APIRequester @@ -167,6 +157,7 @@ def test_get_tasks_path(self, incoming_data, path, base_absolut_url): "orderBy": None, "assigneeId": None, "status": None, + "batchId": None, "offset": 0, "limit": 25, }, @@ -184,6 +175,7 @@ def test_get_tasks_path(self, incoming_data, path, base_absolut_url): ), "assigneeId": 1, "status": None, + "batchId": None, "offset": 0, "limit": 25, }, @@ -201,6 +193,18 @@ def test_get_tasks_path(self, incoming_data, path, base_absolut_url): ), "assigneeId": None, "status": CrowdinTaskStatus.DONE, + "batchId": None, + "offset": 0, + "limit": 25, + }, + ), + ( + {"batchId": 5}, + { + "orderBy": None, + "assigneeId": None, + "status": None, + "batchId": 5, "offset": 0, "limit": 25, }, @@ -260,6 +264,7 @@ def test_add_task(self, m_request, base_absolut_url): "startedAt": None, "dateFrom": None, "dateTo": None, + "batchId": None, }, ), ( @@ -280,6 +285,7 @@ def test_add_task(self, m_request, base_absolut_url): "startedAt": datetime(year=1966, month=2, day=1), "dateFrom": datetime(year=1988, month=1, day=4), "dateTo": datetime(year=2015, month=10, day=13), + "batchId": 5, }, { "title": "title", @@ -298,6 +304,7 @@ def test_add_task(self, m_request, base_absolut_url): "startedAt": datetime(year=1966, month=2, day=1), "dateFrom": datetime(year=1988, month=1, day=4), "dateTo": datetime(year=2015, month=10, day=13), + "batchId": 5, }, ), ), @@ -335,6 +342,7 @@ def test_add_general_task(self, m_add_task, incoming_data, request_data, base_ab "startedAt": None, "dateFrom": None, "dateTo": None, + "batchId": None, }, ), ( @@ -353,6 +361,7 @@ def test_add_general_task(self, m_add_task, incoming_data, request_data, base_ab "startedAt": datetime(year=1966, month=2, day=1), "dateFrom": datetime(year=1988, month=1, day=4), "dateTo": datetime(year=2015, month=10, day=13), + "batchId": 5, }, { "title": "title", @@ -369,6 +378,7 @@ def test_add_general_task(self, m_add_task, incoming_data, request_data, base_ab "startedAt": datetime(year=1966, month=2, day=1), "dateFrom": datetime(year=1988, month=1, day=4), "dateTo": datetime(year=2015, month=10, day=13), + "batchId": 5, }, ), ), @@ -389,19 +399,22 @@ def test_add_general_by_string_ids_task(self, m_add_task, incoming_data, request "title": "title", "languageId": "ua", "fileIds": [1, 2, 3], - "type": LanguageServiceTaskType.TRANSLATE_BY_VENDOR, + "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, + "vendor": "gengo", }, { "title": "title", "languageId": "ua", "fileIds": [1, 2, 3], - "type": LanguageServiceTaskType.TRANSLATE_BY_VENDOR, - "vendor": "crowdin_language_service", + "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, + "vendor": "gengo", "status": None, "description": None, + "skipAssignedStrings": None, + "includePreTranslatedStringsOnly": None, "labelIds": None, "excludeLabelIds": None, - "includePreTranslatedStringsOnly": None, + "deadline": None, "dateFrom": None, "dateTo": None, }, @@ -411,12 +424,15 @@ def test_add_general_by_string_ids_task(self, m_add_task, incoming_data, request "title": "title", "languageId": "ua", "fileIds": [1, 2, 3], - "type": LanguageServiceTaskType.TRANSLATE_BY_VENDOR, + "type": CrowdinTaskType.PROOFREAD_BY_VENDOR, + "vendor": "oht", "status": CrowdinTaskStatus.TODO, "description": "description", + "skipAssignedStrings": False, + "includePreTranslatedStringsOnly": False, "labelIds": [4, 5, 6], "excludeLabelIds": [7, 8, 9], - "includePreTranslatedStringsOnly": False, + "deadline": datetime(year=1988, month=9, day=26), "dateFrom": datetime(year=1988, month=1, day=4), "dateTo": datetime(year=2015, month=10, day=13), }, @@ -424,13 +440,15 @@ def test_add_general_by_string_ids_task(self, m_add_task, incoming_data, request "title": "title", "languageId": "ua", "fileIds": [1, 2, 3], - "type": LanguageServiceTaskType.TRANSLATE_BY_VENDOR, - "vendor": "crowdin_language_service", + "type": CrowdinTaskType.PROOFREAD_BY_VENDOR, + "vendor": "oht", "status": CrowdinTaskStatus.TODO, "description": "description", + "skipAssignedStrings": False, + "includePreTranslatedStringsOnly": False, "labelIds": [4, 5, 6], "excludeLabelIds": [7, 8, 9], - "includePreTranslatedStringsOnly": False, + "deadline": datetime(year=1988, month=9, day=26), "dateFrom": datetime(year=1988, month=1, day=4), "dateTo": datetime(year=2015, month=10, day=13), }, @@ -438,13 +456,11 @@ def test_add_general_by_string_ids_task(self, m_add_task, incoming_data, request ), ) @mock.patch("crowdin_api.api_resources.tasks.resource.TasksResource.add_task") - def test_add_language_service_task( - self, m_add_task, incoming_data, request_data, base_absolut_url - ): + 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_language_service_task(projectId=1, **incoming_data) == "response" + 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( @@ -455,17 +471,20 @@ def test_add_language_service_task( "title": "title", "languageId": "ua", "stringIds": [1, 2, 3], - "type": LanguageServiceTaskType.TRANSLATE_BY_VENDOR, + "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, + "vendor": "gengo", }, { "title": "title", "languageId": "ua", "stringIds": [1, 2, 3], - "type": LanguageServiceTaskType.TRANSLATE_BY_VENDOR, - "vendor": "crowdin_language_service", + "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, + "vendor": "gengo", "status": None, "description": None, + "skipAssignedStrings": None, "includePreTranslatedStringsOnly": None, + "deadline": None, "dateFrom": None, "dateTo": None, }, @@ -475,10 +494,13 @@ def test_add_language_service_task( "title": "title", "languageId": "ua", "stringIds": [1, 2, 3], - "type": LanguageServiceTaskType.TRANSLATE_BY_VENDOR, + "type": CrowdinTaskType.PROOFREAD_BY_VENDOR, + "vendor": "oht", "status": CrowdinTaskStatus.TODO, "description": "description", + "skipAssignedStrings": False, "includePreTranslatedStringsOnly": False, + "deadline": datetime(year=1988, month=9, day=26), "dateFrom": datetime(year=1988, month=1, day=4), "dateTo": datetime(year=2015, month=10, day=13), }, @@ -486,11 +508,13 @@ def test_add_language_service_task( "title": "title", "languageId": "ua", "stringIds": [1, 2, 3], - "type": LanguageServiceTaskType.TRANSLATE_BY_VENDOR, - "vendor": "crowdin_language_service", + "type": CrowdinTaskType.PROOFREAD_BY_VENDOR, + "vendor": "oht", "status": CrowdinTaskStatus.TODO, "description": "description", + "skipAssignedStrings": False, "includePreTranslatedStringsOnly": False, + "deadline": datetime(year=1988, month=9, day=26), "dateFrom": datetime(year=1988, month=1, day=4), "dateTo": datetime(year=2015, month=10, day=13), }, @@ -498,13 +522,13 @@ def test_add_language_service_task( ), ) @mock.patch("crowdin_api.api_resources.tasks.resource.TasksResource.add_task") - def test_add_language_service_by_string_ids_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_language_service_by_string_ids_task(projectId=1, **incoming_data) == "response" + 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( @@ -513,68 +537,44 @@ def test_add_language_service_by_string_ids_task( ( { "title": "title", - "languageId": "ua", - "fileIds": [1, 2, 3], - "type": OhtCrowdinTaskType.TRANSLATE_BY_VENDOR, + "precedingTaskId": 1, }, { - "vendor": "oht", "title": "title", - "languageId": "ua", - "fileIds": [1, 2, 3], - "type": OhtCrowdinTaskType.TRANSLATE_BY_VENDOR, - "status": None, + "precedingTaskId": 1, + "type": CrowdinTaskType.PROOFREAD, "description": None, - "expertise": None, - "editService": None, - "labelIds": None, - "excludeLabelIds": None, - "includePreTranslatedStringsOnly": None, - "dateFrom": None, - "dateTo": None, + "assignees": None, + "deadline": None, }, ), ( { "title": "title", - "languageId": "ua", - "fileIds": [1, 2, 3], - "type": OhtCrowdinTaskType.TRANSLATE_BY_VENDOR, - "status": CrowdinTaskStatus.TODO, + "precedingTaskId": 1, "description": "description", - "expertise": OhtCrowdinTaskExpertise.AD_WORDS_BANNERS, - "editService": True, - "labelIds": [4, 5, 6], - "excludeLabelIds": [7, 8, 9], - "includePreTranslatedStringsOnly": False, - "dateFrom": datetime(year=1988, month=1, day=4), - "dateTo": datetime(year=2015, month=10, day=13), + "assignees": [{"id": 1, "wordsCount": 2}], + "deadline": datetime(year=1988, month=9, day=26), }, { - "vendor": "oht", "title": "title", - "languageId": "ua", - "fileIds": [1, 2, 3], - "type": OhtCrowdinTaskType.TRANSLATE_BY_VENDOR, - "status": CrowdinTaskStatus.TODO, + "precedingTaskId": 1, "description": "description", - "expertise": OhtCrowdinTaskExpertise.AD_WORDS_BANNERS, - "editService": True, - "labelIds": [4, 5, 6], - "excludeLabelIds": [7, 8, 9], - "includePreTranslatedStringsOnly": False, - "dateFrom": datetime(year=1988, month=1, day=4), - "dateTo": datetime(year=2015, month=10, day=13), + "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_vendor_oht_task(self, m_add_task, incoming_data, request_data, base_absolut_url): + 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_vendor_oht_task(projectId=1, **incoming_data) == "response" + 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( @@ -583,678 +583,111 @@ def test_add_vendor_oht_task(self, m_add_task, incoming_data, request_data, base ( { "title": "title", - "languageId": "ua", - "stringIds": [1, 2, 3], - "type": OhtCrowdinTaskType.TRANSLATE_BY_VENDOR, + "precedingTaskId": 1, + "vendor": "crowdin_language_service", }, { - "vendor": "oht", "title": "title", - "languageId": "ua", - "stringIds": [1, 2, 3], - "type": OhtCrowdinTaskType.TRANSLATE_BY_VENDOR, - "status": None, + "precedingTaskId": 1, + "type": CrowdinTaskType.PROOFREAD_BY_VENDOR, + "vendor": "crowdin_language_service", "description": None, - "editService": None, - "expertise": None, - "includePreTranslatedStringsOnly": None, - "dateFrom": None, - "dateTo": None, + "assignees": None, + "deadline": None, }, ), ( { "title": "title", - "languageId": "ua", - "stringIds": [1, 2, 3], - "type": OhtCrowdinTaskType.TRANSLATE_BY_VENDOR, - "status": CrowdinTaskStatus.TODO, + "precedingTaskId": 1, "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": "acclaro", + "assignees": [{"id": 1, "wordsCount": 2}], + "deadline": datetime(year=1988, month=9, day=26), }, { - "vendor": "oht", "title": "title", - "languageId": "ua", - "stringIds": [1, 2, 3], - "type": OhtCrowdinTaskType.TRANSLATE_BY_VENDOR, - "status": CrowdinTaskStatus.TODO, + "precedingTaskId": 1, "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), + "deadline": datetime(year=1988, month=9, day=26), + "type": CrowdinTaskType.PROOFREAD_BY_VENDOR, + "vendor": "acclaro", + "assignees": [{"id": 1, "wordsCount": 2}], }, ), ), ) @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): + def test_add_vendor_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_oht_by_string_ids_task(projectId=1, **incoming_data) == "response" + assert resource.add_vendor_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", - "languageId": "ua", - "fileIds": [1, 2, 3], - }, - { - "vendor": "gengo", - "title": "title", - "languageId": "ua", - "fileIds": [1, 2, 3], - "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, - "status": None, - "description": None, - "expertise": None, - "tone": None, - "purpose": None, - "customerMessage": None, - "usePreferred": None, - "editService": None, - "labelIds": None, - "excludeLabelIds": None, - "dateFrom": None, - "dateTo": None, - }, - ), - ( - { - "title": "title", - "languageId": "ua", - "fileIds": [1, 2, 3], - "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, - "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": "gengo", - "title": "title", - "languageId": "ua", - "fileIds": [1, 2, 3], - "type": CrowdinTaskType.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, - "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_gengo_task(self, m_add_task, incoming_data, request_data, base_absolut_url): - m_add_task.return_value = "response" + @mock.patch("crowdin_api.requester.APIRequester.request") + def test_export_task_strings(self, m_request, base_absolut_url): + m_request.return_value = "response" resource = self.get_resource(base_absolut_url) - assert resource.add_vendor_gengo_task(projectId=1, **incoming_data) == "response" - m_add_task.assert_called_once_with(projectId=1, request_data=request_data) + assert resource.export_task_strings(projectId=1, taskId=2) == "response" + m_request.assert_called_once_with( + method="post", + path=resource.get_tasks_path(projectId=1, taskId=2) + "/exports", + ) + + @mock.patch("crowdin_api.requester.APIRequester.request") + def test_get_task(self, m_request, base_absolut_url): + m_request.return_value = "response" + + resource = self.get_resource(base_absolut_url) + assert resource.get_task(projectId=1, taskId=2) == "response" + m_request.assert_called_once_with( + method="get", path=resource.get_tasks_path(projectId=1, taskId=2) + ) + + @mock.patch("crowdin_api.requester.APIRequester.request") + 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) + ) @pytest.mark.parametrize( - "incoming_data, request_data", + "data", ( - ( - { - "title": "title", - "languageId": "ua", - "stringIds": [1, 2, 3], - }, + [ { - "vendor": "gengo", - "title": "title", - "languageId": "ua", - "stringIds": [1, 2, 3], - "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, - "status": None, - "description": None, - "expertise": None, - "editService": None, - "tone": None, - "purpose": None, - "customerMessage": None, - "usePreferred": None, - "dateFrom": None, - "dateTo": None, - }, - ), - ( + "value": "value", + "op": PatchOperation.REPLACE, + "path": TaskOperationPatchPath.TITLE, + } + ], + [ { - "title": "title", - "languageId": "ua", - "stringIds": [1, 2, 3], - "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), - }, + "value": 5, + "op": PatchOperation.REPLACE, + "path": TaskOperationPatchPath.BATCH_ID, + } + ], + [ { - "vendor": "gengo", - "title": "title", - "languageId": "ua", - "stringIds": [1, 2, 3], - "type": CrowdinTaskType.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), - }, - ), + "value": True, + "op": PatchOperation.REPLACE, + "path": TaskOperationPatchPath.RESET_SCOPE, + } + ], ), ) - @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", - ( - ( - { - "title": "title", - "languageId": "ua", - "fileIds": [1, 2, 3], - }, - { - "vendor": "translated", - "title": "title", - "languageId": "ua", - "fileIds": [1, 2, 3], - "type": CrowdinTaskType.TRANSLATE_BY_VENDOR, - "status": None, - "description": None, - "expertise": None, - "subject": None, - "labelIds": None, - "excludeLabelIds": None, - "dateFrom": None, - "dateTo": None, - }, - ), - ( - { - "title": "title", - "languageId": "ua", - "fileIds": [1, 2, 3], - "status": CrowdinTaskStatus.IN_PROGRESS, - "description": "description", - "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": CrowdinTaskType.TRANSLATE_BY_VENDOR, - "status": CrowdinTaskStatus.IN_PROGRESS, - "description": "description", - "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), - }, - ), - ), - ) - @mock.patch("crowdin_api.api_resources.tasks.resource.TasksResource.add_task") - def test_add_vendor_manual_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_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" - - resource = self.get_resource(base_absolut_url) - assert resource.export_task_strings(projectId=1, taskId=2) == "response" - m_request.assert_called_once_with( - method="post", - path=resource.get_tasks_path(projectId=1, taskId=2) + "/exports", - ) - - @mock.patch("crowdin_api.requester.APIRequester.request") - def test_get_task(self, m_request, base_absolut_url): - m_request.return_value = "response" - - resource = self.get_resource(base_absolut_url) - assert resource.get_task(projectId=1, taskId=2) == "response" - m_request.assert_called_once_with( - method="get", path=resource.get_tasks_path(projectId=1, taskId=2) - ) - @mock.patch("crowdin_api.requester.APIRequester.request") - def test_delete_task(self, m_request, base_absolut_url): + def test_edit_task(self, m_request, data, 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" - - 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( @@ -1478,6 +911,7 @@ def test_add_task_settings_template(self, m_request, base_absolut_url): "startedAt": None, "dateFrom": None, "dateTo": None, + "batchId": None, }, ), ( @@ -1500,6 +934,7 @@ def test_add_task_settings_template(self, m_request, base_absolut_url): "startedAt": datetime(year=1966, month=2, day=1), "dateFrom": datetime(year=1988, month=1, day=4), "dateTo": datetime(year=2015, month=10, day=13), + "batchId": 5, }, { "title": "title", @@ -1520,6 +955,7 @@ def test_add_task_settings_template(self, m_request, base_absolut_url): "startedAt": datetime(year=1966, month=2, day=1), "dateFrom": datetime(year=1988, month=1, day=4), "dateTo": datetime(year=2015, month=10, day=13), + "batchId": 5, }, ), ), @@ -1563,6 +999,7 @@ def test_add_general_task( "startedAt": None, "dateFrom": None, "dateTo": None, + "batchId": None, }, ), ( @@ -1582,6 +1019,7 @@ def test_add_general_task( "startedAt": datetime(year=1966, month=2, day=1), "dateFrom": datetime(year=1988, month=1, day=4), "dateTo": datetime(year=2015, month=10, day=13), + "batchId": 5, }, { "title": "title", @@ -1600,6 +1038,7 @@ def test_add_general_task( "startedAt": datetime(year=1966, month=2, day=1), "dateFrom": datetime(year=1988, month=1, day=4), "dateTo": datetime(year=2015, month=10, day=13), + "batchId": 5, }, ), ), @@ -1642,6 +1081,7 @@ def test_add_general_by_string_ids_task( "deadline": None, "startedAt": None, "dateTo": None, + "batchId": None, }, ), ( @@ -1658,6 +1098,7 @@ def test_add_general_by_string_ids_task( "deadline": datetime(year=1988, month=9, day=26), "startedAt": datetime(year=1966, month=2, day=1), "dateTo": datetime(year=2015, month=10, day=13), + "batchId": 5, }, { "title": "title", @@ -1672,6 +1113,7 @@ def test_add_general_by_string_ids_task( "deadline": datetime(year=1988, month=9, day=26), "startedAt": datetime(year=1966, month=2, day=1), "dateTo": datetime(year=2015, month=10, day=13), + "batchId": 5, }, ), ), @@ -1709,6 +1151,7 @@ def test_add_vendor_task( "deadline": None, "startedAt": None, "dateTo": None, + "batchId": None, }, ), ( @@ -1723,6 +1166,7 @@ def test_add_vendor_task( "deadline": datetime(year=1988, month=9, day=26), "startedAt": datetime(year=1966, month=2, day=1), "dateTo": datetime(year=2015, month=10, day=13), + "batchId": 5, }, { "title": "title", @@ -1735,6 +1179,7 @@ def test_add_vendor_task( "deadline": datetime(year=1988, month=9, day=26), "startedAt": datetime(year=1966, month=2, day=1), "dateTo": datetime(year=2015, month=10, day=13), + "batchId": 5, }, ), ),