Skip to content

Commit

Permalink
[Low Code CDK] Pass DeclarativeStream's name into DefaultSchemaLoad…
Browse files Browse the repository at this point in the history
…er options
  • Loading branch information
clnoll committed Jan 20, 2023
1 parent 8a95c5c commit b562e22
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,10 @@ def create_declarative_stream(model: DeclarativeStreamModel, config: Config, **k
if model.schema_loader:
schema_loader = _create_component_from_model(model=model.schema_loader, config=config)
else:
schema_loader = DefaultSchemaLoader(config=config, options=model.options)
options = model.options or {}
if "name" not in options:
options["name"] = model.name
schema_loader = DefaultSchemaLoader(config=config, options=options)

transformations = []
if model.transformations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,37 @@ def test_add_fields(self):
)
]
assert stream.transformations == expected

def test_default_schema_loader(self):
component_definition = {
"type": "DeclarativeStream",
"name": "test",
"primary_key": [],
"retriever": {
"type": "SimpleRetriever",
"name": "test",
"primary_key": [],
"requester": {
"type": "HttpRequester",
"name": "test",
"url_base": "http://localhost:6767/",
"path": "items/",
"request_options_provider": {
"request_parameters": {},
"request_headers": {},
"request_body_json": {},
"type": "InterpolatedRequestOptionsProvider",
},
"authenticator": {"type": "BearerAuthenticator", "api_token": "{{ config['api_key'] }}"},
},
"record_selector": {"type": "RecordSelector", "extractor": {"type": "DpathExtractor", "field_pointer": ["items"]}},
"paginator": {"type": "NoPagination"},
},
}
resolved_manifest = resolver.preprocess_manifest(component_definition)
propagated_source_config = ManifestComponentTransformer().propagate_types_and_options("", resolved_manifest, {})
stream = factory.create_component(
model_type=DeclarativeStreamModel, component_definition=propagated_source_config, config=input_config
)
schema_loader = stream.schema_loader
assert schema_loader.default_loader._get_json_filepath().split("/")[-1] == f"{stream.name}.json"

0 comments on commit b562e22

Please sign in to comment.