diff options
author | Ross Brattain <ross.b.brattain@intel.com> | 2017-08-15 15:24:30 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-08-15 15:24:30 +0000 |
commit | 42c7c490703248d571c9c4dc97610155b32d003a (patch) | |
tree | 38aa8711d7422e72c54b0183b0fea47c67c39798 /tests/unit | |
parent | d9c0b9e1c2e0a11500fa09c10ba559d4944b720c (diff) | |
parent | 605a15e8d226b7ecb663ca9a088e544b58060d06 (diff) |
Merge "deepgetitem: try string index before int"
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/network_services/vnf_generic/test_vnfdgen.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/unit/network_services/vnf_generic/test_vnfdgen.py b/tests/unit/network_services/vnf_generic/test_vnfdgen.py index be51e4a43..44d9058dc 100644 --- a/tests/unit/network_services/vnf_generic/test_vnfdgen.py +++ b/tests/unit/network_services/vnf_generic/test_vnfdgen.py @@ -193,6 +193,14 @@ class TestVnfdGen(unittest.TestCase): d = {'a': 1, 'b': 2} self.assertEqual(vnfdgen.deepgetitem(d, "a"), 1) + def test_dict_flatten_str_int_key_first(self): + d = {'0': 1, 0: 24, 'b': 2} + self.assertEqual(vnfdgen.deepgetitem(d, "0"), 1) + + def test_dict_flatten_int_key_fallback(self): + d = {0: 1, 'b': 2} + self.assertEqual(vnfdgen.deepgetitem(d, "0"), 1) + def test_dict_flatten_list(self): d = {'a': 1, 'b': list(range(2))} self.assertEqual(vnfdgen.deepgetitem(d, "b.0"), 0) @@ -201,6 +209,11 @@ class TestVnfdGen(unittest.TestCase): d = {'a': 1, 'b': {x: x for x in list(range(2))}} self.assertEqual(vnfdgen.deepgetitem(d, "b.0"), 0) + def test_dict_flatten_only_str_key(self): + d = {'0': 1, 0: 24, 'b': 2} + self.assertRaises(AttributeError, vnfdgen.deepgetitem, d, 0) + + def test_generate_tp_single_var(self): """ Function to verify traffic profile generation with imix """ |