Skip to content

Commit

Permalink
#119 Fixed the json bugs in the bucketfs connection object (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahsimb authored Jun 18, 2024
1 parent 25eb080 commit 18b7c0a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 8 additions & 4 deletions exasol/nb_connector/extension_wrapper_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,14 @@ def encapsulate_bucketfs_credentials(

def to_json_str(**kwargs) -> str:
def format_value(v):
return f'"{v}"' if isinstance(v, str) else v

return ", ".join(f'"{k}":{format_value(v)}' for k, v in kwargs.items()
if v is not None)
if isinstance(v, str):
return f'"{v}"'
elif isinstance(v, bool):
return str(v).lower()
return v

return "{" + ", ".join(f'"{k}":{format_value(v)}' for k, v in kwargs.items()
if v is not None) + "}"

backend = get_backend(conf)
if backend == StorageBackend.onprem:
Expand Down
2 changes: 2 additions & 0 deletions test/unit/test_extension_wrapper_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def validate_params(actual_params: str, expected_params: tuple[list[str], list[A
for param_name, param_value in zip(*expected_params):
if isinstance(param_value, str):
param_value = f'"{param_value}"'
elif isinstance(param_value, bool):
param_value = str(param_value).lower()
expected_pattern = rf'"{param_name}":\s*{param_value}'
assert re.search(expected_pattern, actual_params) is not None

Expand Down

0 comments on commit 18b7c0a

Please sign in to comment.