Failure of test case 47/9847/2
authorves-dev <prajakta.dhivar@xoriant.com>
Mon, 28 Nov 2022 12:38:20 +0000 (18:08 +0530)
committersantanu de <santanu.de@xoriant.com>
Tue, 29 Nov 2022 06:39:31 +0000 (06:39 +0000)
SMO-106

Signed-off-by: ves-dev <prajakta.dhivar@xoriant.com>
Change-Id: If60eb64af6545f8314b1a39320af0a64c3408961

tests/dmaap_adaptor/test_config.conf [new file with mode: 0644]
tests/dmaap_adaptor/test_consumer.py

diff --git a/tests/dmaap_adaptor/test_config.conf b/tests/dmaap_adaptor/test_config.conf
new file mode 100644 (file)
index 0000000..f72ba0a
--- /dev/null
@@ -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 =
index 1fca142..fa7340d 100644 (file)
@@ -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):