Skip to content

Commit

Permalink
Renamed the property per code review feedback and added another test …
Browse files Browse the repository at this point in the history
…case.
  • Loading branch information
tdilauro committed Jan 23, 2025
1 parent a08e52c commit fef092a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/palace/manager/integration/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class ConfigurationFormItem(LoggerMixin):
weight: int = 0

# If set to True, the Admin UI will be directed to hide this field.
suppressed: bool = False
hidden: bool = False

@staticmethod
def get_form_value(value: Any) -> Any:
Expand All @@ -261,7 +261,7 @@ def to_dict(
"label": self.label,
"key": key,
"required": required or self.required,
"suppressed": self.suppressed,
"hidden": self.hidden,
}

if required and not self.required:
Expand Down
42 changes: 26 additions & 16 deletions tests/manager/integration/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,22 @@ def __init__(self):
"key": "test",
"label": "Test",
"required": False,
"suppressed": False,
"hidden": False,
}
self.number_config_dict = {
"description": "Number description",
"key": "number",
"label": "Number",
"required": True,
"suppressed": False,
"hidden": False,
}
self.with_alias_config_dict = {
"default": -1.1,
"description": "With Alias description",
"key": "with_alias",
"label": "With Alias",
"required": False,
"suppressed": False,
"hidden": False,
}
self.mock_db = MagicMock(spec=Session)
self.settings = partial(MockSettings, number=1)
Expand Down Expand Up @@ -258,30 +258,40 @@ def test_configuration_form_suppressed(
base_settings_fixture: BaseSettingsFixture,
) -> None:
class MockConfigSettings(BaseSettings):
unsuppressed_field: str = FormField(
explicitly_unhidden_field: str = FormField(
"default",
form=ConfigurationFormItem(
label="Unsuppressed",
description="An unsuppressed field",
label="Explicitly Unhidden",
description="An explicitly unhidden field",
hidden=False,
),
)
suppressed_field: str = FormField(
implicitly_unhidden_field: str = FormField(
"default",
form=ConfigurationFormItem(
label="Suppressed",
description="Suppressed field with default value",
suppressed=True,
label="Implicitly Unhidden",
description="An implicitly unhidden field",
),
)
hidden_field: str = FormField(
"default",
form=ConfigurationFormItem(
label="Hidden",
description="An explicitly hidden field",
hidden=True,
),
)

[item1, item2] = MockConfigSettings().configuration_form(
[item1, item2, item3] = MockConfigSettings().configuration_form(
base_settings_fixture.mock_db
)

assert item1["key"] == "unsuppressed_field"
assert item1["suppressed"] is False
assert item2["key"] == "suppressed_field"
assert item2["suppressed"] is True
assert item1["key"] == "explicitly_unhidden_field"
assert item1["hidden"] is False
assert item2["key"] == "implicitly_unhidden_field"
assert item2["hidden"] is False
assert item3["key"] == "hidden_field"
assert item3["hidden"] is True

def test_configuration_form_options(
self, base_settings_fixture: BaseSettingsFixture
Expand Down Expand Up @@ -353,6 +363,6 @@ class AdditionalSettings(BaseSettings):
"key": "test",
"label": "Test",
"required": False,
"suppressed": False,
"hidden": False,
}
]

0 comments on commit fef092a

Please sign in to comment.