Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def import_(args, api_client=NEW_API_CLIENT) -> list[str]:
vars_to_update = []
for k, v in var_json.items():
value, description = v, None
if isinstance(v, dict) and v.get("value"):
if isinstance(v, dict) and "value" in v:
value, description = v["value"], v.get("description")

vars_to_update.append(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,37 @@ def test_import_success(self, api_client_maker, tmp_path, monkeypatch):
)
assert response == [self.key]

@pytest.mark.parametrize(
"falsy_value",
[
"",
0,
False,
],
ids=["empty_string", "zero", "false"],
)
def test_import_falsy_values(self, api_client_maker, tmp_path, monkeypatch, falsy_value):
"""Test that falsy values (empty string, 0, False) are correctly imported."""
api_client = api_client_maker(
path="/api/v2/variables",
response_json=self.bulk_response_success.model_dump(),
expected_http_status_code=200,
kind=ClientKind.CLI,
)

monkeypatch.chdir(tmp_path)
expected_json_path = tmp_path / self.export_file_name
variable_file = {
self.key: {"value": falsy_value, "description": "test falsy value"},
}

expected_json_path.write_text(json.dumps(variable_file))
response = variable_command.import_(
self.parser.parse_args(["variables", "import", expected_json_path.as_posix()]),
api_client=api_client,
)
assert response == [self.key]

def test_import_error(self, api_client_maker, tmp_path, monkeypatch):
api_client = api_client_maker(
path="/api/v2/variables",
Expand Down
Loading