diff --git a/project_rossum_deploy/commands/download/helpers.py b/project_rossum_deploy/commands/download/helpers.py index d3c8eaa..9336f25 100644 --- a/project_rossum_deploy/commands/download/helpers.py +++ b/project_rossum_deploy/commands/download/helpers.py @@ -153,6 +153,33 @@ async def check_schema_formula_fields_existence(remote_object: dict, path: Path) ... +async def check_email_template_existence( + client: ElisAPIClient, remote_object: dict, path: Path +): + try: + queue = await client._http_client.request_json( + method="GET", url=remote_object["queue"] + ) + if not queue["workspace"]: + raise MissingParentObjectException + ws = await client._http_client.request_json( + method="GET", url=queue["workspace"] + ) + except (APIClientError, MissingParentObjectException) as e: + if e.status_code != 404: + raise e + + raise MissingParentObjectException + + # Suffix = email_templates / .json + compare_paths( + original_path=path, + ws=ws, + queue=queue, + suffix=Path(path.parent.name) / path.name, + ) + + async def remove_local_nonexistent_object( path: Path, client: ElisAPIClient, @@ -210,6 +237,8 @@ async def remove_local_nonexistent_object( await check_inbox_existence(client, remote_object, path) elif object_type == Resource.Schema: await check_schema_formula_fields_existence(remote_object, path) + elif object_type == Resource.EmailTemplate: + await check_email_template_existence(client, remote_object, path) except ( APIClientError, @@ -287,7 +316,11 @@ def compare_paths(original_path: Path, ws, queue, suffix): queue_path_path = templatize_name_id(queue["name"], queue["id"]) path_parts = str(original_path).split("/") latest_path = ( - Path(*path_parts[:-4]) / ws_path_part / "queues" / queue_path_path / suffix + Path(*path_parts[: -5 if "email_templates" in str(suffix) else -4]) + / ws_path_part + / "queues" + / queue_path_path + / suffix ) # If the original path was absollut @@ -348,7 +381,8 @@ async def determine_object_destination( destination = settings.SOURCE_DIRNAME else: object_name, object_id = object["name"], object["id"] - user_decision = Confirm.ask( + # TODO: fix logic + user_decision = Confirm( f'Should the {object_type} "{object_name}" ({object_id}) be in {settings.SOURCE_DIRNAME}? Otherwise, it will be understood as {settings.TARGET_DIRNAME}.' ) destination = ( diff --git a/tests/reference_project/prd_config.yaml b/tests/reference_project/prd_config.yaml new file mode 100644 index 0000000..ab91223 --- /dev/null +++ b/tests/reference_project/prd_config.yaml @@ -0,0 +1,3 @@ +source_api_base: https://shared-eu2.rossum.app/api/v1 +use_same_org_as_target: true +target_api_base: '' diff --git a/tests/reference_project/source/hooks/Business Rules Validation_[360148].json b/tests/reference_project/source/hooks/Business Rules Validation_[360148].json index 4d3a264..286ac23 100644 --- a/tests/reference_project/source/hooks/Business Rules Validation_[360148].json +++ b/tests/reference_project/source/hooks/Business Rules Validation_[360148].json @@ -30,7 +30,9 @@ "app": null, "payload_logging_enabled": false, "timeout_s": 30, + "max_polling_time_s": 300, "retry_count": 4, + "retry_count_for_polling_failure": 0, "insecure_ssl": false, "client_ssl_certificate": null, "retry_on_any_non_2xx": false @@ -54,5 +56,5 @@ "token_lifetime_s": null, "hook_template": "https://shared-eu2.rossum.app/api/v1/hook_templates/30", "modified_by": "https://shared-eu2.rossum.app/api/v1/users/285991", - "modified_at": "2024-08-14T13:42:23.661462Z" + "modified_at": "2024-09-17T06:50:38.010407Z" } \ No newline at end of file diff --git a/tests/reference_project/source/hooks/Custom Hook_[360147].json b/tests/reference_project/source/hooks/Custom Hook_[360147].json index a6edf4f..1dcb8e2 100644 --- a/tests/reference_project/source/hooks/Custom Hook_[360147].json +++ b/tests/reference_project/source/hooks/Custom Hook_[360147].json @@ -21,7 +21,9 @@ "app": null, "payload_logging_enabled": false, "timeout_s": 30, + "max_polling_time_s": 300, "retry_count": 4, + "retry_count_for_polling_failure": 0, "url": "https://shared-eu2.rossum.app/settings/extensions/create", "secret": null, "insecure_ssl": false, @@ -45,5 +47,5 @@ "token_lifetime_s": null, "hook_template": null, "modified_by": "https://shared-eu2.rossum.app/api/v1/users/285991", - "modified_at": "2024-08-13T09:44:28.066752Z" + "modified_at": "2024-08-19T08:59:13.912998Z" } \ No newline at end of file diff --git a/tests/reference_project/source/organization.json b/tests/reference_project/source/organization.json index 52621fe..6641f19 100644 --- a/tests/reference_project/source/organization.json +++ b/tests/reference_project/source/organization.json @@ -27,6 +27,6 @@ "creator": "https://shared-eu2.rossum.app/api/v1/users/285991", "settings": {}, "modified_by": "https://shared-eu2.rossum.app/api/v1/users/285991", - "modified_at": "2024-08-14T13:41:40.413544Z", + "modified_at": "2024-09-17T06:49:42.779725Z", "sandbox": false } \ No newline at end of file diff --git a/tests/reference_project/source/schemas/Tax invoices (EU) schema_[1241833].json b/tests/reference_project/source/schemas/Tax invoices (EU) schema_[1241833].json index 06dee3a..f0fb29c 100644 --- a/tests/reference_project/source/schemas/Tax invoices (EU) schema_[1241833].json +++ b/tests/reference_project/source/schemas/Tax invoices (EU) schema_[1241833].json @@ -1202,5 +1202,5 @@ ], "metadata": {}, "modified_by": "https://shared-eu2.rossum.app/api/v1/users/285991", - "modified_at": "2024-08-14T13:39:55.612296Z" + "modified_at": "2024-09-17T06:47:15.546513Z" } \ No newline at end of file