From 157d966c50f06241bc6ca471616d4708e8d1fab4 Mon Sep 17 00:00:00 2001 From: wenxin Date: Wed, 23 Nov 2022 14:12:55 +0800 Subject: [PATCH] remove test case about register --- 0002-remove-test-case-about-register.patch | 118 +++++++++++++++++++++ aops-ceres.spec | 11 +- 2 files changed, 125 insertions(+), 4 deletions(-) create mode 100644 0002-remove-test-case-about-register.patch diff --git a/0002-remove-test-case-about-register.patch b/0002-remove-test-case-about-register.patch new file mode 100644 index 0000000..2097888 --- /dev/null +++ b/0002-remove-test-case-about-register.patch @@ -0,0 +1,118 @@ +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 + diff --git a/aops-ceres.spec b/aops-ceres.spec index ecaff3a..d4a0d2d 100644 --- a/aops-ceres.spec +++ b/aops-ceres.spec @@ -1,17 +1,17 @@ Name: aops-ceres Version: v1.0.0 -Release: 2 +Release: 3 Summary: An agent which needs to be adopted in client, it managers some plugins, such as gala-gopher(kpi collection), fluentd(log collection) and so on. License: MulanPSL2 URL: https://gitee.com/openeuler/%{name} Source0: %{name}-%{version}.tar.gz Patch0001: 0001-add-field-os_version-for-register.patch - +Patch0002: 0002-remove-test-case-about-register.patch 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 @@ -42,8 +42,11 @@ An agent which needs to be adopted in client, it managers some plugins, such as %changelog +* Wed Nov 23 2022 wenxin - v1.0.0-3 +- remove test case: remove test case about register + * Wed Nov 23 2022 wenxin - v1.0.0-2 - update register: add field os_version for register - + * Tue Nov 22 2022 zhuyuncheng - v1.0.0-1 - Package init