X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FRO.git;a=blobdiff_plain;f=NG-RO%2Fosm_ng_ro%2Ftests%2Ftest_ns.py;h=4cfc30bccfb3bc524c1f4a96768e8329795cbb72;hp=7e6757aa2286241b5533e292f00e9c948db65bb2;hb=abdfe78edd8719f0578321afe631914df512976e;hpb=648ee3dda65699ddfdd01d9f363fb2e37e99930c diff --git a/NG-RO/osm_ng_ro/tests/test_ns.py b/NG-RO/osm_ng_ro/tests/test_ns.py index 7e6757aa..4cfc30bc 100644 --- a/NG-RO/osm_ng_ro/tests/test_ns.py +++ b/NG-RO/osm_ng_ro/tests/test_ns.py @@ -162,7 +162,9 @@ class TestNs(unittest.TestCase): expected_result = { "find_params": {}, } - target_image = {"no_image": "to_see_here"} + target_image = { + "no_image": "to_see_here", + } result = Ns._process_image_params( target_image=target_image, @@ -180,7 +182,9 @@ class TestNs(unittest.TestCase): }, }, } - target_image = {"image": "cirros"} + target_image = { + "image": "cirros", + } result = Ns._process_image_params( target_image=target_image, @@ -198,7 +202,9 @@ class TestNs(unittest.TestCase): }, }, } - target_image = {"vim_image_id": "123456"} + target_image = { + "vim_image_id": "123456", + } result = Ns._process_image_params( target_image=target_image, @@ -216,7 +222,9 @@ class TestNs(unittest.TestCase): }, }, } - target_image = {"image_checksum": "e3fc50a88d0a364313df4b21ef20c29e"} + target_image = { + "image_checksum": "e3fc50a88d0a364313df4b21ef20c29e", + } result = Ns._process_image_params( target_image=target_image, @@ -225,3 +233,85 @@ class TestNs(unittest.TestCase): ) self.assertDictEqual(expected_result, result) + + def test__get_resource_allocation_params_with_empty_target_image(self): + expected_result = {} + quota_descriptor = {} + + result = Ns._get_resource_allocation_params( + quota_descriptor=quota_descriptor, + ) + + self.assertDictEqual(expected_result, result) + + def test__get_resource_allocation_params_with_wrong_target_image(self): + expected_result = {} + quota_descriptor = { + "no_quota": "present_here", + } + + result = Ns._get_resource_allocation_params( + quota_descriptor=quota_descriptor, + ) + + self.assertDictEqual(expected_result, result) + + def test__get_resource_allocation_params_with_limit(self): + expected_result = { + "limit": 10, + } + quota_descriptor = { + "limit": "10", + } + + result = Ns._get_resource_allocation_params( + quota_descriptor=quota_descriptor, + ) + + self.assertDictEqual(expected_result, result) + + def test__get_resource_allocation_params_with_reserve(self): + expected_result = { + "reserve": 20, + } + quota_descriptor = { + "reserve": "20", + } + + result = Ns._get_resource_allocation_params( + quota_descriptor=quota_descriptor, + ) + + self.assertDictEqual(expected_result, result) + + def test__get_resource_allocation_params_with_shares(self): + expected_result = { + "shares": 30, + } + quota_descriptor = { + "shares": "30", + } + + result = Ns._get_resource_allocation_params( + quota_descriptor=quota_descriptor, + ) + + self.assertDictEqual(expected_result, result) + + def test__get_resource_allocation_params(self): + expected_result = { + "limit": 10, + "reserve": 20, + "shares": 30, + } + quota_descriptor = { + "limit": "10", + "reserve": "20", + "shares": "30", + } + + result = Ns._get_resource_allocation_params( + quota_descriptor=quota_descriptor, + ) + + self.assertDictEqual(expected_result, result)