Skip to content

Commit

Permalink
custom parse faker config to array
Browse files Browse the repository at this point in the history
  • Loading branch information
pnadolny13 committed Feb 15, 2024
1 parent 42c2fc6 commit 570273d
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
4 changes: 3 additions & 1 deletion hub_utils/meltano_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@ def _get_kind_from_type(type, name, enforce_desc):
kind = type

if not kind:
if enforce_desc:
if name == "faker_config.locale":
kind = "array"
elif enforce_desc:
kind = typer.prompt(f"[{name}] `kind`", default="string")
else:
name = name
Expand Down
62 changes: 62 additions & 0 deletions tests/data/faker_configs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"name": "tap-faker-example",
"description": "Faker tap class.",
"version": "[could not be detected]",
"sdk_version": "0.35.0",
"supported_python_versions": null,
"capabilities": [],
"settings": {
"type": "object",
"properties": {
"faker_config": {
"type": [
"object",
"null"
],
"properties": {
"seed": {
"oneOf": [
{
"type": [
"number"
]
},
{
"type": [
"string"
]
},
{
"type": [
"boolean"
]
}
],
"description": "Value to seed the Faker generator for deterministic output: https://faker.readthedocs.io/en/master/#seeding-the-generator"
},
"locale": {
"oneOf": [
{
"type": [
"string"
]
},
{
"type": "array",
"items": {
"type": [
"string"
]
}
}
],
"description": "One or more LCID locale strings to produce localized output for: https://faker.readthedocs.io/en/master/#localization"
}
},
"description": "Config for the [`Faker`](https://faker.readthedocs.io/en/master/) instance variable `fake` used within map expressions. Only applicable if the plugin specifies `faker` as an addtional dependency (through the `singer-sdk` `faker` extra or directly)."
}
},
"required": []
}
}

19 changes: 19 additions & 0 deletions tests/test_meltano_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,3 +537,22 @@ def test_get_quality(input, expected):
)
def test_clean_description(input, expected):
assert MeltanoUtil._clean_description(input) == expected


def test_sdk_about_parsing_faker_configs():
sdk_about_dict = _read_data('faker_configs.json')
settings, _, _ = MeltanoUtil._parse_sdk_about_settings(sdk_about_dict)
assert settings == [
{
"name": "faker_config.seed",
"label": "Faker Config Seed",
"description": "Value to seed the Faker generator for deterministic output: https://faker.readthedocs.io/en/master/#seeding-the-generator",
"kind": "string"
},
{
"name": "faker_config.locale",
"label": "Faker Config Locale",
"description": "One or more LCID locale strings to produce localized output for: https://faker.readthedocs.io/en/master/#localization",
"kind": "array"
}
]

0 comments on commit 570273d

Please sign in to comment.