Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CV2-5387: no langid in healthcheck #456

Merged
merged 2 commits into from
Sep 30, 2024
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
14 changes: 7 additions & 7 deletions app/main/controller/healthcheck_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def get(self):
'ELASTICSEARCH_SIMILARITY': False,
'REDIS': False,
'DATABASE': False,
'LANGID': False
# 'LANGID': False
}

# Elasticsearch
Expand Down Expand Up @@ -50,11 +50,11 @@ def get(self):
except Exception as e:
result['DATABASE'] = str(e)

# Langid
try:
class_ = getattr(importlib.import_module('app.main.lib.langid'), app.config['PROVIDER_LANGID'].title() + 'LangidProvider')
result['LANGID'] = class_.test()
except Exception as e:
result['LANGID'] = '%s: %s' % (app.config['PROVIDER_LANGID'].title() + 'LangidProvider', str(e))
# # Langid
# try:
# class_ = getattr(importlib.import_module('app.main.lib.langid'), app.config['PROVIDER_LANGID'].title() + 'LangidProvider')
# result['LANGID'] = class_.test()
# except Exception as e:
# result['LANGID'] = '%s: %s' % (app.config['PROVIDER_LANGID'].title() + 'LangidProvider', str(e))

return { 'result': result }, 200 if all(x and type(x) == type(True) for x in result.values()) else 500
10 changes: 5 additions & 5 deletions app/test/test_healthcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ def test_healthcheck_api_with_bad_config(self):
self.assertEqual('application/json', response.content_type)
self.assertEqual(500, response.status_code)

def test_healthcheck_api_with_import_error(self):
with patch.dict('sys.modules', {'app.main.lib.langid': None}):
response = self.client.get('/healthcheck/')
self.assertEqual('application/json', response.content_type)
self.assertEqual(500, response.status_code)
# def test_healthcheck_api_with_import_error(self):
# with patch.dict('sys.modules', {'app.main.lib.langid': None}):
# response = self.client.get('/healthcheck/')
# self.assertEqual('application/json', response.content_type)
# self.assertEqual(500, response.status_code)

if __name__ == '__main__':
unittest.main()
Loading