From 1edf979b873b01f2ced61d10077b43680ccb8a71 Mon Sep 17 00:00:00 2001 From: ves-dev Date: Mon, 28 Nov 2022 18:08:20 +0530 Subject: [PATCH] Failure of test case SMO-106 Signed-off-by: ves-dev Change-Id: If60eb64af6545f8314b1a39320af0a64c3408961 --- tests/dmaap_adaptor/test_config.conf | 22 ++++++++++++++++++++ tests/dmaap_adaptor/test_consumer.py | 40 ++++++++++++++++++------------------ 2 files changed, 42 insertions(+), 20 deletions(-) create mode 100644 tests/dmaap_adaptor/test_config.conf diff --git a/tests/dmaap_adaptor/test_config.conf b/tests/dmaap_adaptor/test_config.conf new file mode 100644 index 0000000..f72ba0a --- /dev/null +++ b/tests/dmaap_adaptor/test_config.conf @@ -0,0 +1,22 @@ +# Copyright 2021 Xoriant Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#------------------------------------------------------------------------------ +# This is a config file for the dmaap-adapter. +# + +[default] +log_file = dmaap.log +log_level = error +kafka_broker = kafka +enable_assert = diff --git a/tests/dmaap_adaptor/test_consumer.py b/tests/dmaap_adaptor/test_consumer.py index 1fca142..fa7340d 100644 --- a/tests/dmaap_adaptor/test_consumer.py +++ b/tests/dmaap_adaptor/test_consumer.py @@ -62,11 +62,28 @@ def get_path(): def get_config_path(): project_path = get_path() - config_path = os.path.join(project_path, "dmaapadapter/adapter/config/adapter.conf") + config_path = os.path.join(project_path, "tests/dmaap_adaptor/test_config.conf") return config_path -# test __init__ of TpoicConsumer +@mock.patch("confluent_kafka.Consumer") +def test_consumeEvents(mock_consumer, prepareResponse, topic, resCode): + consumergroup = "test" + consumerid = "test1" + limit = 10 + timeout = 1 + mock_consumer.__name__ = "subscribe" + mock_consumer.__name__ = "poll" + mock_consumer.poll.return_value = None + EventConsumer.consumeEvents( + EventConsumer, prepareResponse, topic, consumergroup, consumerid, limit, timeout + ) + resMsg = "[]" + assert resCode == prepareResponse.getResponseCode() + assert resMsg == prepareResponse.getResponseMsg() + + +# test __init__()function of TpoicConsumer @mock.patch("app_config.AppConfig.setLogger") @mock.patch( "argparse.ArgumentParser.parse_args", @@ -77,7 +94,7 @@ def test_init_consumer(parser, mock_setLogger): mock_setLogger.assert_called_with("dmaap.log", "error") -# test __init__ of EventConsumer +# test __init__() function of EventConsumer @mock.patch("app_config.AppConfig.setLogger") @mock.patch( "argparse.ArgumentParser.parse_args", @@ -88,23 +105,6 @@ def test_init_event(parser, mock_setLogger): mock_setLogger.assert_called_with("dmaap.log", "error") -@mock.patch("confluent_kafka.Consumer") -def test_consumeEvents(mock_consumer, prepareResponse, topic, resCode): - consumergroup = "test" - consumerid = "test1" - limit = 10 - timeout = 1 - mock_consumer.__name__ = "subscribe" - mock_consumer.__name__ = "poll" - mock_consumer.poll.return_value = None - EventConsumer.consumeEvents( - EventConsumer, prepareResponse, topic, consumergroup, consumerid, limit, timeout - ) - resMsg = "[]" - assert resCode == prepareResponse.getResponseCode() - assert resMsg == prepareResponse.getResponseMsg() - - # test consumeEvents for break @mock.patch("confluent_kafka.Consumer") def test_consumeEvents_break(mock_consumer, prepareResponse, topic, resCode): -- 2.16.6