Skip to content

Commit 27f2057

Browse files
committed
fix migration and unit tests, and add variables to unit tests
1 parent 623f0e7 commit 27f2057

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

airbyte_cdk/manifest_migrations/migrations/http_requester_request_body_json_data_to_request_body.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def _migrate_body_json(self, manifest: ManifestType, key: str) -> None:
5454
if isinstance(manifest[key], str):
5555
self._migrate_value(manifest, key, text_type)
5656
elif isinstance(manifest[key], dict):
57-
if manifest[key].get(query_key) is not None:
57+
if isinstance(manifest[key].get(query_key), str):
5858
self._migrate_value(manifest, key, graph_ql_type)
5959
else:
6060
self._migrate_value(manifest, key, json_object_type)

unit_tests/manifest_migrations/conftest.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -740,9 +740,8 @@ def manifest_with_request_body_json_and_data_to_migrate_to_request_body() -> Dic
740740
# the `request_body_json` is expected to be migrated to the `request_body` key,
741741
# this example holds the GraphQL query object.
742742
"request_body_json": {
743-
"query": {
744-
"query { {{ config['query_field'] }} { {{ config['query_value'] }} }}",
745-
}
743+
"query": "query { {{ config['query_field'] }} { {{ config['query_value'] }} }}",
744+
"variables": {"arg1": "test"}
746745
},
747746
},
748747
"record_selector": {
@@ -975,6 +974,7 @@ def expected_manifest_with_migrated_to_request_body() -> Dict[str, Any]:
975974
"type": "RequestBodyGraphQL",
976975
"value": {
977976
"query": "query { {{ config['query_field'] }} { {{ config['query_value'] }} }}",
977+
"variables": {"arg1": "test"},
978978
},
979979
},
980980
},
@@ -1135,6 +1135,7 @@ def expected_manifest_with_migrated_to_request_body() -> Dict[str, Any]:
11351135
"type": "RequestBodyGraphQL",
11361136
"value": {
11371137
"query": "query { {{ config['query_field'] }} { {{ config['query_value'] }} }}",
1138+
"variables": {"arg1": "test"},
11381139
},
11391140
},
11401141
},

unit_tests/sources/declarative/requesters/request_options/test_interpolated_request_options_provider.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,11 @@ def test_interpolated_request_json(test_name, input_request_json, expected_reque
239239
RequestBodyGraphQL(
240240
type="RequestBodyGraphQL",
241241
value=RequestBodyGraphQlQuery(
242-
query="query { {{ config['option'] }} }"
242+
query="query { {{ config['option'] }} }",
243+
variables={"startDate": "{{ stream_interval['start_date'] }}"},
243244
),
244245
),
245-
{"query": "query { OPTION }"},
246+
{"query": "query { OPTION }", "variables": {"startDate": "2020-01-01"}},
246247
),
247248
],
248249
)

0 commit comments

Comments
 (0)