diff options
author | Abhijeet Kasurde <akasurde@redhat.com> | 2019-07-08 18:56:00 +0530 |
---|---|---|
committer | Brian Coca <bcoca@users.noreply.github.com> | 2019-07-08 09:25:59 -0400 |
commit | 79fdc2190a799e59bdc2c9c9c0f0937bde924cf0 (patch) | |
tree | f87d0c0a7ed512fa0195042348eb6f060672a4e1 /test/units/playbook | |
parent | 894d19b1088d8d4872ca0dd2b9588f196b9a34ea (diff) | |
download | ansible-79fdc2190a799e59bdc2c9c9c0f0937bde924cf0.tar.gz |
role: Fix role's hash_params (#55263)
* role: Fix role's hash_params
Fix based upon work done by alikins.
Fixes: #20596
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
* review comments
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Diffstat (limited to 'test/units/playbook')
-rw-r--r-- | test/units/playbook/role/test_role.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/units/playbook/role/test_role.py b/test/units/playbook/role/test_role.py index b6386a99e6..f94037e911 100644 --- a/test/units/playbook/role/test_role.py +++ b/test/units/playbook/role/test_role.py @@ -118,6 +118,52 @@ class TestHashParams(unittest.TestCase): self.assertRaises(TypeError, hash_params, params) + def test_param_dict_dupe_values(self): + params1 = {'foo': False} + params2 = {'bar': False} + + res1 = hash_params(params1) + res2 = hash_params(params2) + + hash1 = hash(res1) + hash2 = hash(res2) + self.assertNotEqual(res1, res2) + self.assertNotEqual(hash1, hash2) + + def test_param_dupe(self): + params1 = { + # 'from_files': {}, + 'tags': [], + u'testvalue': False, + u'testvalue2': True, + # 'when': [] + } + params2 = { + # 'from_files': {}, + 'tags': [], + u'testvalue': True, + u'testvalue2': False, + # 'when': [] + } + res1 = hash_params(params1) + res2 = hash_params(params2) + + self.assertNotEqual(hash(res1), hash(res2)) + self.assertNotEqual(res1, res2) + + foo = {} + foo[res1] = 'params1' + foo[res2] = 'params2' + + self.assertEqual(len(foo), 2) + + del foo[res2] + self.assertEqual(len(foo), 1) + + for key in foo: + self.assertTrue(key in foo) + self.assertIn(key, foo) + class TestRole(unittest.TestCase): |