Skip to content

Commit

Permalink
Refactor /info response (#514)
Browse files Browse the repository at this point in the history
Moved evaluate_enabled flag inside features field

Co-authored-by: Chinmay Gore <[email protected]>
  • Loading branch information
cgore1 and Chinmay Gore authored Aug 6, 2021
1 parent bc2c020 commit c6fc744
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
1 change: 1 addition & 0 deletions tabpy/tabpy_server/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ def _get_features(self):
"methods": {"basic-auth": {}},
}

features["evaluate_enabled"] = self.settings[SettingsParameters.EvaluateEnabled]
return features

def _build_tabpy_state(self):
Expand Down
1 change: 0 additions & 1 deletion tabpy/tabpy_server/handlers/service_info_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ def get(self):
info["server_version"] = self.settings[SettingsParameters.ServerVersion]
info["name"] = self.tabpy_state.name
info["versions"] = self.settings[SettingsParameters.ApiVersions]
info["evaluate_enabled"] = self.settings[SettingsParameters.EvaluateEnabled]
self.write(json.dumps(info))
9 changes: 3 additions & 6 deletions tests/unit/server_tests/test_service_info_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ def _create_expected_info_response(settings, tabpy_state):
"state_path": settings["state_file_path"],
"server_version": settings[SettingsParameters.ServerVersion],
"name": tabpy_state.name,
"versions": settings["versions"],
"evaluate_enabled": settings["evaluate_enabled"]
"versions": settings["versions"]
}


Expand Down Expand Up @@ -101,10 +100,9 @@ def test_given_server_with_auth_expect_correct_info_response(self):
self.assertTrue("features" in v1)
features = v1["features"]
self.assertDictEqual(
{"authentication": {"methods": {"basic-auth": {}}, "required": True}},
{"authentication": {"methods": {"basic-auth": {}}, "required": True}, 'evaluate_enabled': True},
features,
)
self.assertTrue(actual_response['evaluate_enabled'])


class TestServiceInfoHandlerWithoutAuth(BaseTestServiceInfoHandler):
Expand All @@ -128,8 +126,7 @@ def test_server_with_no_auth_expect_correct_info_response(self):
v1 = versions["v1"]
self.assertTrue("features" in v1)
features = v1["features"]
self.assertDictEqual({}, features)
self.assertTrue(actual_response['evaluate_enabled'])
self.assertDictEqual({'evaluate_enabled': True}, features)

def test_given_server_with_no_auth_and_password_expect_correct_info_response(self):
header = {
Expand Down

0 comments on commit c6fc744

Please sign in to comment.