Browse Source

!228 Fix function too long.

Merge pull request !228 from yuximiao/master
tags/v0.5.0-beta
mindspore-ci-bot Gitee 5 years ago
parent
commit
56e2723388
2 changed files with 9 additions and 4 deletions
  1. +1
    -1
      mindinsight/profiler/common/validator/validate.py
  2. +8
    -3
      tests/ut/backend/profiler/test_profiler_restful_api.py

+ 1
- 1
mindinsight/profiler/common/validator/validate.py View File

@@ -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)


+ 8
- 3
tests/ut/backend/profiler/test_profiler_restful_api.py View File

@@ -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)


Loading…
Cancel
Save