From: rl001m Date: Tue, 13 Mar 2018 18:36:52 +0000 (-0400) Subject: Added more unit test cases in aai.py file X-Git-Tag: v1.1.1~43^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=aeb730c21aebede0a7df2b29247afa6fc473b73c;p=optf%2Fhas.git Added more unit test cases in aai.py file 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 --- 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 index 0000000..9dd4514 --- /dev/null +++ b/conductor/conductor/tests/unit/data/plugins/inventory_provider/_cached_complex.json @@ -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 index 0000000..feba03b --- /dev/null +++ b/conductor/conductor/tests/unit/data/plugins/inventory_provider/relationship_list.json @@ -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 diff --git a/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_aai.py b/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_aai.py index 30a54a9..802168f 100644 --- a/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_aai.py +++ b/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_aai.py @@ -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