From f4ed851b85ebbc442e523c3e8c06ef45a030cd99 Mon Sep 17 00:00:00 2001 From: wenxin Date: Wed, 23 Nov 2022 13:58:14 +0800 Subject: [PATCH 1/1] remove test case about register --- aops-ceres.spec | 2 +- ceres/tests/function/test_register.py | 53 +-------------------------- setup.py | 3 +- 3 files changed, 3 insertions(+), 55 deletions(-) diff --git a/aops-ceres.spec b/aops-ceres.spec index 0eef858..230c983 100644 --- a/aops-ceres.spec +++ b/aops-ceres.spec @@ -10,7 +10,7 @@ Source0: %{name}-%{version}.tar.gz BuildRequires: python3-setuptools Requires: python3-requests python3-flask python3-connexion python3-configparser python3-jsonschema Requires: python3-flask-testing python3-libconf python3-swagger-ui-bundle -Requires: python3-concurrent-log-handler dmidecode python3-responses +Requires: python3-concurrent-log-handler dmidecode Provides: aops-ceres Conflicts: aops-agent diff --git a/ceres/tests/function/test_register.py b/ceres/tests/function/test_register.py index 312ca32..96c4a2d 100644 --- a/ceres/tests/function/test_register.py +++ b/ceres/tests/function/test_register.py @@ -11,41 +11,13 @@ # See the Mulan PSL v2 for more details. # ******************************************************************************/ import unittest -from unittest import mock - -import responses -from ceres.manages.collect_manage import Collect from ceres.function.register import register, register_info_to_dict -from ceres.function.status import SUCCESS, PARAM_ERROR +from ceres.function.status import PARAM_ERROR class TestRegister(unittest.TestCase): - @responses.activate - @mock.patch('builtins.open', mock.mock_open()) - @mock.patch.object(Collect, "get_system_info") - def test_register_should_return_200_when_input_correct(self, mock_os_version): - mock_os_version.return_value = 'mock version' - input_data = { - "web_username": "admin", - "web_password": "changeme", - "host_name": "host01", - "host_group_name": "2333", - "management": False, - "manager_ip": "127.0.0.1", - "manager_port": "11111", - "agent_port": "12000" - } - responses.add(responses.POST, - 'http://127.0.0.1:11111/manage/host/add', - json={"token": "hdahdahiudahud", "code": SUCCESS}, - status=SUCCESS, - content_type='application/json' - ) - data = register(input_data) - self.assertEqual(SUCCESS, data) - def test_register_should_return_param_error_when_input_web_username_is_null(self): input_data = { "web_password": "changeme", @@ -234,29 +206,6 @@ class TestRegister(unittest.TestCase): data = register(input_data) self.assertEqual(data, PARAM_ERROR) - @responses.activate - @mock.patch('builtins.open', mock.mock_open()) - @mock.patch.object(Collect, "get_system_info") - def test_register_should_return_success_when_input_with_no_agent_port(self, mock_os_version): - mock_os_version.return_value = "mock version" - responses.add(responses.POST, - 'http://127.0.0.1:11111/manage/host/add', - json={"token": "hdahdahiudahud", "code": SUCCESS}, - status=SUCCESS, - content_type='application/json' - ) - input_data = { - "web_username": "admin", - "web_password": "changeme", - "host_name": "host01", - "host_group_name": "2333", - "management": False, - "manager_ip": "127.0.0.1", - "manager_port": "11111", - } - data = register(input_data) - self.assertEqual(SUCCESS, data) - def test_register_info_to_dict_should_return_dict_info_when_input_is_correct(self): mock_string = '{"mock": "mock"}' res = register_info_to_dict(mock_string) diff --git a/setup.py b/setup.py index a00a39f..645def0 100644 --- a/setup.py +++ b/setup.py @@ -14,8 +14,7 @@ INSTALL_REQUIRES = [ "libconf", "connexion", "swagger-ui-bundle>=0.0.2", - "concurrent_log_handler", - "responses" + "concurrent_log_handler" ] setup( -- 2.37.1.windows.1