aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHansen, Tony (th1395) <th1395@att.com>2022-08-19 12:56:56 +0000
committerHansen, Tony (th1395) <th1395@att.com>2022-08-19 12:57:10 +0000
commitdac22d93c804780f2dc20164aeb44fc80a30890d (patch)
tree7bd19b04ffa5e8fb049068d9de79778eeed140de /tests
parent554b15356ef100a3617f7f5415f6a35ac2b3ebba (diff)
lots of cleanup, no functional code changes
Change-Id: I9eefe4d34ae226bbd5a6f80422f89baeeaeb3471 Signed-off-by: Hansen, Tony (th1395) <th1395@att.com> Issue-ID: DCAEGEN2-2837
Diffstat (limited to 'tests')
-rw-r--r--tests/monkey_psycopg2.py12
-rw-r--r--tests/test_binding.py23
-rw-r--r--tests/test_check_health.py5
-rw-r--r--tests/test_htbtworker.py6
-rw-r--r--tests/test_trapd_get_cbs_config.py69
-rw-r--r--tests/test_trapd_settings.py10
-rw-r--r--tests/test_trapd_vnf_table.py4
7 files changed, 108 insertions, 21 deletions
diff --git a/tests/monkey_psycopg2.py b/tests/monkey_psycopg2.py
index e993874..c87aedf 100644
--- a/tests/monkey_psycopg2.py
+++ b/tests/monkey_psycopg2.py
@@ -1,5 +1,5 @@
# ============LICENSE_START====================================================
-# Copyright (c) 2017-2021 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2017-2022 AT&T Intellectual Property. All rights reserved.
# =============================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -106,7 +106,7 @@ class MockConn(object):
if FORCE_CURSOR_FAILURE:
raise psycopg2.DatabaseError(f"Unable to return cursor: force_cursor_failure=<{FORCE_CURSOR_FAILURE}>")
- print(f"cursor()")
+ print("cursor()")
self.curCursor = None
return self
@@ -128,10 +128,10 @@ class MockConn(object):
raise Exception("postgres execute command throwing exception. cmd=<{}>".format(cmd))
if self.dbInfo:
- curCmdLower = cmd.lower()
+ cur_cmd_lower = cmd.lower()
for cmd, val in self.dbInfo.items():
print(f"cmd={cmd}, val={val}")
- if cmd in curCmdLower:
+ if cmd in cur_cmd_lower:
self.curCursor = val
break
@@ -140,7 +140,7 @@ class MockConn(object):
return a single row from the current cursor
"""
if not self.curCursor:
- print(f"fetchone() returning None")
+ print("fetchone() returning None")
return None
print(f"fetchone() returning {self.curCursor[0]}")
return self.curCursor[0]
@@ -150,7 +150,7 @@ class MockConn(object):
return all rows from the current cursor
"""
if not self.curCursor:
- print(f"fetchall() returning None")
+ print("fetchall() returning None")
return None
print(f"fetchall() returning {self.curCursor}")
return self.curCursor
diff --git a/tests/test_binding.py b/tests/test_binding.py
index 5ed6532..ae3221f 100644
--- a/tests/test_binding.py
+++ b/tests/test_binding.py
@@ -1,5 +1,5 @@
# ============LICENSE_START=======================================================
-# Copyright (c) 2017-2021 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2017-2022 AT&T Intellectual Property. All rights reserved.
# Copyright (c) 2019 Pantheon.tech. All rights reserved.
# Copyright (c) 2021 Samsung Electronics. All rights reserved.
# Copyright (c) 2021 Fujitsu Ltd.
@@ -45,7 +45,26 @@ def disable_proxy(monkeypatch):
@httpretty.activate
def test_resolve_all(disable_proxy):
- htbtmsg = '{"event":{"commonEventHeader":{"startEpochMicrosec":1518616063564475,"sourceId":"587c14b3-72c0-4581-b5cb-6567310b9bb7","eventId":"10048640","reportingEntityId":"587c14b3-72c0-4581-b5cb-6567310b9bb7","priority":"Normal","version":3,"reportingEntityName":"TESTVM","sequence":10048640,"domain":"heartbeat","lastEpochMicrosec":1518616063564476,"eventName":"Heartbeat_vVnf","sourceName":"TESTVM","nfNamingCode":"vVNF"}}}'
+ htbtmsg = (
+ "{"
+ '"event": {'
+ ' "commonEventHeader":{'
+ ' "startEpochMicrosec":1518616063564475,'
+ ' "sourceId":"587c14b3-72c0-4581-b5cb-6567310b9bb7",'
+ ' "eventId":"10048640",'
+ ' "reportingEntityId":"587c14b3-72c0-4581-b5cb-6567310b9bb7",'
+ ' "priority":"Normal",'
+ ' "version":3,'
+ ' "reportingEntityName":"TESTVM",'
+ ' "sequence":10048640,'
+ ' "domain":"heartbeat",'
+ ' "lastEpochMicrosec":1518616063564476,'
+ ' "eventName":"Heartbeat_vVnf",'
+ ' "sourceName":"TESTVM",'
+ ' "nfNamingCode":"vVNF"}'
+ " }"
+ "}"
+ )
send_url = mr_url + "/events/" + intopic + "/DefaultGroup/1?timeout=15000"
print(send_url)
httpretty.register_uri(httpretty.GET, send_url, body=htbtmsg)
diff --git a/tests/test_check_health.py b/tests/test_check_health.py
index d77beb1..b2ae276 100644
--- a/tests/test_check_health.py
+++ b/tests/test_check_health.py
@@ -1,5 +1,5 @@
# ============LICENSE_START=======================================================
-# Copyright (c) 2017-2021 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2017-2022 AT&T Intellectual Property. All rights reserved.
# Copyright (c) 2019 Pantheon.tech. All rights reserved.
# Copyright (c) 2021 Fujitsu Ltd.
# ================================================================================
@@ -16,7 +16,8 @@
# limitations under the License.
# ============LICENSE_END=========================================================
-# code loosely based on https://stackoverflow.com/questions/25369068/python-how-to-unit-test-a-custom-http-request-handler
+# code loosely based on
+# https://stackoverflow.com/questions/25369068/python-how-to-unit-test-a-custom-http-request-handler
from miss_htbt_service import check_health
diff --git a/tests/test_htbtworker.py b/tests/test_htbtworker.py
index 11cdc4a..78c9087 100644
--- a/tests/test_htbtworker.py
+++ b/tests/test_htbtworker.py
@@ -1,5 +1,5 @@
# ============LICENSE_START=======================================================
-# Copyright (c) 2020-2021 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2020-2022 AT&T Intellectual Property. All rights reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -16,7 +16,9 @@
from miss_htbt_service import htbtworker
-import os, tempfile, json
+import os
+import tempfile
+import json
def run_test(i):
diff --git a/tests/test_trapd_get_cbs_config.py b/tests/test_trapd_get_cbs_config.py
index ffb9bfb..75e2055 100644
--- a/tests/test_trapd_get_cbs_config.py
+++ b/tests/test_trapd_get_cbs_config.py
@@ -1,5 +1,5 @@
# ============LICENSE_START=======================================================
-# Copyright (c) 2017-2021 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2017-2022 AT&T Intellectual Property. All rights reserved.
# Copyright (c) 2019 Pantheon.tech. All rights reserved.
# Copyright (c) 2021 Fujitsu Ltd.
# ================================================================================
@@ -28,7 +28,72 @@ class test_get_cbs_config(unittest.TestCase):
Test the trapd_get_cbs_config mod
"""
- pytest_json_data = '{ "heartbeat_config": { "vnfs": [{ "eventName": "Heartbeat_vDNS", "heartbeatcountmissed": 3, "heartbeatinterval": 60, "closedLoopControlName": "ControlLoopEvent1", "policyVersion": "1.0.0.5", "policyName": "vFireWall", "policyScope": "resource=sampleResource,type=sampletype,CLName=sampleCLName", "target_type": "VNF", "target": "genVnfName", "version": "1.0" }, { "eventName": "Heartbeat_vFW", "heartbeatcountmissed": 3, "heartbeatinterval": 60, "closedLoopControlName": "ControlLoopEvent1", "policyVersion": "1.0.0.5", "policyName": "vFireWall", "policyScope": "resource=sampleResource,type=sampletype,CLName=sampleCLName", "target_type": "VNF", "target": "genVnfName", "version": "1.0" }, { "eventName": "Heartbeat_xx", "heartbeatcountmissed": 3, "heartbeatinterval": 60, "closedLoopControlName": "ControlLoopEvent1", "policyVersion": "1.0.0.5", "policyName": "vFireWall", "policyScope": "resource=sampleResource,type=sampletype,CLName=sampleCLName", "target_type": "VNF", "target": "genVnfName", "version": "1.0" } ] }, "streams_publishes": { "ves_heartbeat": { "dmaap_info": { "topic_url": "http://message-router:3904/events/unauthenticated.DCAE_CL_OUTPUT/" }, "type": "message_router" } }, "streams_subscribes": { "ves_heartbeat": { "dmaap_info": { "topic_url": "http://message-router:3904/events/unauthenticated.SEC_HEARTBEAT_INPUT/" }, "type": "message_router" } } }'
+ pytest_json_data = (
+ "{"
+ ' "heartbeat_config": {'
+ ' "vnfs": ['
+ " {"
+ ' "eventName": "Heartbeat_vDNS",'
+ ' "heartbeatcountmissed": 3,'
+ ' "heartbeatinterval": 60,'
+ ' "closedLoopControlName": "ControlLoopEvent1",'
+ ' "policyVersion": "1.0.0.5",'
+ ' "policyName": "vFireWall",'
+ ' "policyScope": "resource=sampleResource,'
+ " type=sampletype,"
+ ' CLName=sampleCLName",'
+ ' "target_type": "VNF",'
+ ' "target": "genVnfName",'
+ ' "version": "1.0"'
+ " },"
+ " {"
+ ' "eventName": "Heartbeat_vFW",'
+ ' "heartbeatcountmissed": 3,'
+ ' "heartbeatinterval": 60,'
+ ' "closedLoopControlName": "ControlLoopEvent1",'
+ ' "policyVersion": "1.0.0.5",'
+ ' "policyName": "vFireWall",'
+ ' "policyScope": "resource=sampleResource,'
+ " type=sampletype,"
+ ' CLName=sampleCLName",'
+ ' "target_type": "VNF",'
+ ' "target": "genVnfName",'
+ ' "version": "1.0"'
+ " },"
+ " {"
+ ' "eventName": "Heartbeat_xx",'
+ ' "heartbeatcountmissed": 3,'
+ ' "heartbeatinterval": 60,'
+ ' "closedLoopControlName": "ControlLoopEvent1",'
+ ' "policyVersion": "1.0.0.5",'
+ ' "policyName": "vFireWall",'
+ ' "policyScope": "resource=sampleResource,'
+ " type=sampletype,"
+ ' CLName=sampleCLName",'
+ ' "target_type": "VNF",'
+ ' "target": "genVnfName",'
+ ' "version": "1.0"'
+ " }"
+ " ]"
+ " },"
+ ' "streams_publishes": {'
+ ' "ves_heartbeat": {'
+ ' "dmaap_info": {'
+ ' "topic_url": "http://message-router:3904/events/unauthenticated.DCAE_CL_OUTPUT/"'
+ " },"
+ ' "type": "message_router"'
+ " }"
+ " },"
+ ' "streams_subscribes": {'
+ ' "ves_heartbeat": {'
+ ' "dmaap_info": {'
+ ' "topic_url": "http://message-router:3904/events/unauthenticated.SEC_HEARTBEAT_INPUT/"'
+ " },"
+ ' "type": "message_router"'
+ " }"
+ " }"
+ "}"
+ )
# create copy of snmptrapd.json for pytest
pytest_json_config = "/tmp/opt/app/miss_htbt_service/etc/config.json"
diff --git a/tests/test_trapd_settings.py b/tests/test_trapd_settings.py
index f3aebdd..743fa68 100644
--- a/tests/test_trapd_settings.py
+++ b/tests/test_trapd_settings.py
@@ -1,5 +1,5 @@
# ============LICENSE_START=======================================================
-# Copyright (c) 2017-2021 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2017-2022 AT&T Intellectual Property. All rights reserved.
# Copyright (c) 2019 Pantheon.tech. All rights reserved.
# Copyright (c) 2021 Fujitsu Ltd.
# ================================================================================
@@ -37,7 +37,7 @@ class test_cleanup_and_exit(unittest.TestCase):
try:
tds.no_such_var
result = True
- except:
+ except Exception:
result = False
self.assertEqual(result, False)
@@ -50,7 +50,7 @@ class test_cleanup_and_exit(unittest.TestCase):
try:
tds.c_config
result = True
- except:
+ except Exception:
result = False
self.assertEqual(result, True)
@@ -63,7 +63,7 @@ class test_cleanup_and_exit(unittest.TestCase):
try:
tds.dns_cache_ip_to_name
result = True
- except:
+ except Exception:
result = False
self.assertEqual(result, True)
@@ -76,6 +76,6 @@ class test_cleanup_and_exit(unittest.TestCase):
try:
tds.dns_cache_ip_expires
result = True
- except:
+ except Exception:
result = False
self.assertEqual(result, True)
diff --git a/tests/test_trapd_vnf_table.py b/tests/test_trapd_vnf_table.py
index b88b4d5..2e0f22a 100644
--- a/tests/test_trapd_vnf_table.py
+++ b/tests/test_trapd_vnf_table.py
@@ -1,5 +1,5 @@
# ============LICENSE_START=======================================================
-# Copyright (c) 2017-2021 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2017-2022 AT&T Intellectual Property. All rights reserved.
# Copyright (c) 2019 Pantheon.tech. All rights reserved.
# Copyright (c) 2020 Deutsche Telekom. All rights reserved.
# Copyright (c) 2021 Fujitsu Ltd.
@@ -17,7 +17,7 @@
# limitations under the License.
# ============LICENSE_END=========================================================
#
-## Author Prakask H (ph553f)
+# Author Prakask H (ph553f)
"""
test_trapd_vnf_table contains test cases related to DB Tables and cbs polling.
"""