提交 56e27233 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!228 Fix function too long.

Merge pull request !228 from yuximiao/master
......@@ -133,7 +133,7 @@ def validate_sort_condition(search_condition, search_scope):
if "type" in sort_condition:
sorted_type_param = ['ascending', 'descending']
sorted_type = sort_condition.get("type")
if sorted_type not in sorted_type_param:
if sorted_type and sorted_type not in sorted_type_param:
err_msg = "The sorted type must be ascending or descending."
log.error(err_msg)
raise ProfilerSortConditionException(err_msg)
......
......@@ -50,17 +50,14 @@ class TestProfilerRestfulApi(TestCase):
self.assertEqual(200, response.status_code)
self.assertDictEqual(expect_result, response.get_json())
@mock.patch('mindinsight.backend.lineagemgr.lineage_api.settings')
@mock.patch('mindinsight.profiler.analyser.base_analyser.BaseAnalyser.query')
def test_ops_search_failed(self, *args):
"""Test the failed of ops/search."""
base_dir = '/path/to/test_profiler_base'
expect_result = {
'object': ["test"],
'count': 1
}
args[0].return_value = expect_result
args[1].SUMMARY_BASE_DIR = base_dir
response = self.app_client.post(self.url, data=json.dumps(1))
self.assertEqual(400, response.status_code)
expect_result = {
......@@ -89,6 +86,14 @@ class TestProfilerRestfulApi(TestCase):
del result["error_msg"]
self.assertDictEqual(expect_result, result)
@mock.patch('mindinsight.profiler.analyser.base_analyser.BaseAnalyser.query')
def test_ops_search_search_condition_failed(self, *args):
"""Test search condition error."""
expect_result = {
'object': ["test"],
'count': 1
}
args[0].return_value = expect_result
body_data = {"op_type": "aicore_type", "device_id": "1", "group_condition": 1}
response = self.app_client.post(self.url, data=json.dumps(body_data))
self.assertEqual(400, response.status_code)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册