Added more unit test cases in aai.py file 51/35551/1
authorrl001m <ruilu@research.att.com>
Tue, 13 Mar 2018 18:36:52 +0000 (14:36 -0400)
committerrl001m <ruilu@research.att.com>
Tue, 13 Mar 2018 18:37:07 +0000 (14:37 -0400)
Added more unit tests for AAI.
get_aai_rel_link and get_aai_rel_link_data Usage

Change-Id: Ie5bc835013da5333b7e2c6f19f48ad8910793643
Issue-ID: OPTFRA-101
Signed-off-by: rl001m <ruilu@research.att.com>
conductor/conductor/tests/unit/data/plugins/inventory_provider/_cached_complex.json [new file with mode: 0644]
conductor/conductor/tests/unit/data/plugins/inventory_provider/relationship_list.json [new file with mode: 0644]
conductor/conductor/tests/unit/data/plugins/inventory_provider/test_aai.py

diff --git a/conductor/conductor/tests/unit/data/plugins/inventory_provider/_cached_complex.json b/conductor/conductor/tests/unit/data/plugins/inventory_provider/_cached_complex.json
new file mode 100644 (file)
index 0000000..9dd4514
--- /dev/null
@@ -0,0 +1,8 @@
+{
+     "country": "USA",
+     "region": "SE",
+     "latitude": "28.543251",
+     "longitude": "-81.377112",
+     "city": "Middletwon",
+     "state": "NJ"
+}
\ No newline at end of file
diff --git a/conductor/conductor/tests/unit/data/plugins/inventory_provider/relationship_list.json b/conductor/conductor/tests/unit/data/plugins/inventory_provider/relationship_list.json
new file mode 100644 (file)
index 0000000..feba03b
--- /dev/null
@@ -0,0 +1,20 @@
+{
+     "relationship-list": {
+         "relationship": [
+             {
+                 "related-to": "service-instance",
+                 "related-link": "relationship-link",
+                 "relationship-data": [
+                     {
+                         "relationship-key": "customer.global-customer-id",
+                         "relationship-value": "customer-id"
+                     },
+                     {
+                         "relationship-key": "service-subscription.service-type",
+                         "relationship-value": "service-type"
+                     }
+                 ]
+             }
+         ]
+     }
+ }
\ No newline at end of file
index 30a54a9..802168f 100644 (file)
@@ -21,6 +21,7 @@ import unittest
 import mock
 import conductor.data.plugins.inventory_provider.aai as aai
 from conductor.data.plugins.inventory_provider.aai import AAI
+from conductor.common import rest
 from oslo_config import cfg
 
 class TestAAI(unittest.TestCase):
@@ -217,7 +218,7 @@ class TestAAI(unittest.TestCase):
         regions_response_file = './conductor/tests/unit/data/plugins/inventory_provider/cache_regions.json'
         regions_response = json.loads(open(regions_response_file).read())
 
-        complex_json_file = './conductor/tests/unit/data/plugins/inventory_provider/_get_complex.json'
+        complex_json_file = './conductor/tests/unit/data/plugins/inventory_provider/_cached_complex.json'
         complex_json = json.loads(open(complex_json_file).read())
 
         response = mock.MagicMock()
@@ -232,4 +233,13 @@ class TestAAI(unittest.TestCase):
         self.mock_get_complex.start()
 
         self.assertEqual(None,
-                         self.aai_ep._refresh_cache())
\ No newline at end of file
+                         self.aai_ep._refresh_cache())
+
+    def test_get_aai_rel_link(self):
+
+        relatonship_response_file = './conductor/tests/unit/data/plugins/inventory_provider/relationship_list.json'
+        relatonship_response = json.loads(open(relatonship_response_file).read())
+        related_to = "service-instance"
+
+        self.assertEqual("relationship-link",
+                         self.aai_ep._get_aai_rel_link(relatonship_response, related_to))
\ No newline at end of file