summaryrefslogtreecommitdiffstats
path: root/tests/_test_trapd_get_cbs_config.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/_test_trapd_get_cbs_config.py')
-rw-r--r--tests/_test_trapd_get_cbs_config.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/_test_trapd_get_cbs_config.py b/tests/_test_trapd_get_cbs_config.py
new file mode 100644
index 0000000..5fcfc2a
--- /dev/null
+++ b/tests/_test_trapd_get_cbs_config.py
@@ -0,0 +1,44 @@
+import pytest
+import unittest
+import os
+from onap_dcae_cbs_docker_client.client import get_config
+from trapd_exit import cleanup_and_exit
+from trapd_logging import stdout_logger
+import trapd_get_cbs_config
+
+class test_get_cbs_config(unittest.TestCase):
+ """
+ Test the trapd_get_cbs_config mod
+ """
+
+ def test_cbs_env_present(self):
+ """
+ Test that CBS env variable exists and we can get config even
+ if CONSUL_HOST doesn't provide
+ """
+ os.environ.update(CONSUL_HOST='nosuchhost')
+ result = trapd_get_cbs_config.trapd_get_cbs_config()
+ compare = str(result).startswith("{'snmptrap': ")
+ self.assertEqual(compare, False)
+
+ def test_cbs_fallback_env_present(self):
+ """
+ Test that CBS fallback env variable exists and we can get config
+ from fallback env var
+ """
+ os.environ.update(CBS_SIM_JSON='../etc/snmptrapd.json')
+ result = trapd_get_cbs_config.trapd_get_cbs_config()
+ compare = str(result).startswith("{'snmptrap': ")
+ self.assertEqual(compare, False)
+
+ def test_cbs_fallback_env_not_present(self):
+ """
+ Test that CBS fallback env variable does not exists fails
+ """
+ os.environ.update(CBS_SIM_JSON='../etc/no_such_file.json')
+ result = trapd_get_cbs_config.trapd_get_cbs_config()
+ compare = str(result).startswith("{'snmptrap': ")
+ self.assertEqual(compare, False)
+
+if __name__ == '__main__':
+ unittest.main()