Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
format and lint
  • Loading branch information
swainn committed Jan 8, 2024
1 parent 851cc59 commit 05536ed
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
5 changes: 5 additions & 0 deletions tests/apps/tethysapp-test_app/tethysapp/test_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ def custom_settings(self):
name="default_name",
type=CustomSetting.TYPE_STRING,
description="Default model name.",
include_in_api=True,
required=True,
),
CustomSetting(
name="max_count",
type=CustomSetting.TYPE_INTEGER,
description="Maximum allowed count in a method.",
include_in_api=False,
required=False,
),
CustomSetting(
Expand All @@ -57,6 +59,7 @@ def custom_settings(self):
name="enable_feature",
type=CustomSetting.TYPE_BOOLEAN,
description="Enable this feature when True.",
include_in_api=True,
required=False,
),
JSONCustomSetting(
Expand All @@ -72,6 +75,7 @@ def custom_settings(self):
JSONCustomSetting(
name="JSON_setting_default_value_required",
description="This is JSON setting with a default value",
include_in_api=True,
required=True,
default={"Test": "JSON test String"},
),
Expand All @@ -84,6 +88,7 @@ def custom_settings(self):
SecretCustomSetting(
name="Secret_Test_required",
description="This is SECRET setting with required True",
include_in_api=True,
required=True,
),
SecretCustomSetting(
Expand Down
7 changes: 5 additions & 2 deletions tests/unit_tests/test_tethys_portal/test_views/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,13 @@ def test_get_app_authenticated(self):
)
self.assertDictEqual(
{
"change_factor": {"type": "FLOAT", "value": None},
"JSON_setting_default_value_required": {
"type": "JSON",
"value": {"Test": "JSON test String"},
},
"Secret_Test_required": {"type": "SECRET", "value": None},
"default_name": {"type": "STRING", "value": None},
"enable_feature": {"type": "BOOLEAN", "value": None},
"max_count": {"type": "INTEGER", "value": None},
},
json["customSettings"],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@


class Migration(migrations.Migration):

dependencies = [
('tethys_apps', '0004_rename_display_external_proxyapp_display_external_icon'),
("tethys_apps", "0004_rename_display_external_proxyapp_display_external_icon"),
]

operations = [
migrations.AddField(
model_name='customsettingbase',
name='include_in_api',
model_name="customsettingbase",
name="include_in_api",
field=models.BooleanField(default=False),
),
]
6 changes: 4 additions & 2 deletions tethys_portal/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def get_app(request, app):
if request.user.is_authenticated:
metadata["customSettings"] = dict()
for s in app.custom_settings:
if s.type_custom_setting != "SIMPLE":
if not s.include_in_api:
continue

v = None
Expand All @@ -73,7 +73,9 @@ def get_app(request, app):
pass

metadata["customSettings"][s.name] = {
"type": s.type,
"type": s.type
if s.type_custom_setting == "SIMPLE"
else s.type_custom_setting,
"value": v,
}

Expand Down

0 comments on commit 05536ed

Please sign in to comment.