From 39f6885b0bb29edfa9890fe3fc1c9b9bab708bdb Mon Sep 17 00:00:00 2001 From: Anton Karpets Date: Wed, 29 Nov 2023 13:49:24 +0200 Subject: [PATCH] Update migration --- .../config_migrations.py | 8 +----- .../unit_tests/test_migrations.py | 25 +++---------------- 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/config_migrations.py b/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/config_migrations.py index 83dc461d13e6..093fda40bd45 100644 --- a/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/config_migrations.py +++ b/airbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/config_migrations.py @@ -103,16 +103,10 @@ def _should_migrate(cls, config: Mapping[str, Any]) -> bool: @classmethod def _transform_report_options(cls, config: Mapping[str, Any]) -> Mapping[str, Any]: try: - report_options = json.loads(config.get("report_options", "")) + report_options = json.loads(config.get("report_options", "{}") or "{}") except json.JSONDecodeError: report_options = {} - try: - advanced_stream_options = json.loads(config.get("advanced_stream_options", "")) - except json.JSONDecodeError: - advanced_stream_options = {} - - report_options.update(advanced_stream_options) report_options_list = [] for stream_name, options in report_options.items(): options_list = [{"option_name": name, "option_value": value} for name, value in options.items()] diff --git a/airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_migrations.py b/airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_migrations.py index 1a0bf22665d5..7ff6c7fb1958 100644 --- a/airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_migrations.py +++ b/airbyte-integrations/connectors/source-amazon-seller-partner/unit_tests/test_migrations.py @@ -54,27 +54,9 @@ class TestMigrateReportOptions: {"report_options": "{\"GET_REPORT\": {\"reportPeriod\": \"WEEK\"}}"}, [{"stream_name": "GET_REPORT", "options_list": [{"option_name": "reportPeriod", "option_value": "WEEK"}]}], ), - ( - {"advanced_stream_options": "{\"GET_REPORT\": {\"reportPeriod\": \"WEEK\"}}"}, - [{"stream_name": "GET_REPORT", "options_list": [{"option_name": "reportPeriod", "option_value": "WEEK"}]}], - ), - ( - { - "report_options": "{\"GET_REPORT\": {\"reportPeriod\": \"WEEK\"}}", - "advanced_stream_options": "{\"GET_REPORT_2\": {\"reportPeriod_2\": \"DAY\"}}", - }, - [ - {"stream_name": "GET_REPORT", "options_list": [{"option_name": "reportPeriod", "option_value": "WEEK"}]}, - {"stream_name": "GET_REPORT_2", "options_list": [{"option_name": "reportPeriod_2", "option_value": "DAY"}]}, - ], - ), - ( - { - "report_options": "{\"GET_REPORT\": {\"reportPeriod\": \"WEEK\"}}", - "advanced_stream_options": "{\"GET_REPORT\": {\"reportPeriod\": \"DAY\"}}", - }, - [{"stream_name": "GET_REPORT", "options_list": [{"option_name": "reportPeriod", "option_value": "DAY"}]}], - ), + ({"report_options": None}, []), + ({"report_options": "{{}"}, []), + ({}, []), ), ) def test_transform_report_options(self, input_config, expected_report_options_list): @@ -92,7 +74,6 @@ def test_migrate_config(self, capsys): migrated_config = control_msg["control"]["connectorConfig"]["config"] expected_report_options_list = [ {"stream_name": "GET_REPORT", "options_list": [{"option_name": "reportPeriod", "option_value": "WEEK"}]}, - {"stream_name": "GET_REPORT_2", "options_list": [{"option_name": "reportPeriod_2", "option_value": "DAY"}]}, ] assert migrated_config["report_options_list"] == expected_report_options_list