summaryrefslogtreecommitdiffstats
path: root/test/adapters
diff options
context:
space:
mode:
authorSastry Isukapalli <sastry@research.att.com>2018-02-11 21:09:32 -0500
committerSastry Isukapalli <sastry@research.att.com>2018-02-11 21:16:26 -0500
commit2d2ac618f8538fe243c292540fedfbf45e19b118 (patch)
treef8dbb42efb35d7e79a56978dfbd2e2cb03cbe0e0 /test/adapters
parent0b855c08fd98fb8fa0f4bc40d8df430c897b4bad (diff)
Removed unused DB-adapters, test cases, 60+% cover
We are not using OracleDB, PostgresDB, and VerticaDB, so there is no need to keep the "dead code" -- we can always add it back as needed. Added test cases so that all the files are at least minimally covered. Overall coverage on my local tox shows 66% coverage (I manually ensured all files are included in the coverage report). Issue-ID: OPTFRA-95 Change-Id: If1cab112236b4f32a96315308ce815088fa092d1 Signed-off-by: Sastry Isukapalli <sastry@research.att.com>
Diffstat (limited to 'test/adapters')
-rw-r--r--test/adapters/test_message_router.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/adapters/test_message_router.py b/test/adapters/test_message_router.py
new file mode 100644
index 0000000..2a02dc8
--- /dev/null
+++ b/test/adapters/test_message_router.py
@@ -0,0 +1,44 @@
+import osdf.adapters.dcae.message_router as MR
+import unittest
+
+from osdf.operation.exceptions import MessageBusConfigurationException
+from unittest.mock import patch
+
+
+class TestMessageRouter(unittest.TestCase):
+
+ def test_valid_MR(self):
+ mr = MR.MessageRouterClient(dmaap_url="https://MYHOST:3905")
+
+ def test_valid_MR_with_base_urls(self):
+ base_urls = ["https://MYHOST1:3905/","https://MYHOST2:3905/"]
+ mr = MR.MessageRouterClient(mr_host_base_urls=base_urls, topic="MY-TOPIC")
+
+ def test_invalid_valid_MR_with_base_urls(self):
+ """Topic missing"""
+ base_urls = ["https://MYHOST1:3905/","https://MYHOST2:3905/"]
+ try:
+ mr = MR.MessageRouterClient(mr_host_base_urls=base_urls)
+ except MessageBusConfigurationException:
+ return
+
+ raise Exception("Allows invalid MR configuration") # if it failed to error out
+
+ @patch('osdf.adapters.dcae.message_router.MessageRouterClient.http_request', return_value={})
+ def test_mr_http_request_mocked(self, http_request):
+ mr = MR.MessageRouterClient(dmaap_url="https://MYHOST:3905")
+ mr.http_request = http_request
+ assert mr.get() == {}
+ assert mr.post("Hello") == {}
+
+ def test_mr_http_request_non_existent_host(self):
+ mr = MR.MessageRouterClient(dmaap_url="https://MYHOST:3905")
+ try:
+ mr.get()
+ except:
+ return
+
+ raise Exception("Allows invalid host") # if it failed to error out
+if __name__ == "__main__":
+ unittest.main()
+