mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
fixed type mapper and added tests (#20963)
This commit is contained in:
parent
8d5f4dda06
commit
c33812450e
2 changed files with 13 additions and 1 deletions
|
@ -618,5 +618,5 @@ def map_complex_type(complex_type, type_map):
|
|||
complex_type[i],
|
||||
type_map))
|
||||
elif type_map:
|
||||
return vars(globals()['__builtins__'])[type_map](complex_type)
|
||||
return globals()['__builtins__'][type_map](complex_type)
|
||||
return new_type
|
||||
|
|
12
test/units/modules/cloud/amazon/test_ec2_utils.py
Normal file
12
test/units/modules/cloud/amazon/test_ec2_utils.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
import unittest
|
||||
|
||||
from ansible.module_utils.ec2 import map_complex_type
|
||||
|
||||
|
||||
class Ec2Utils(unittest.TestCase):
|
||||
def test_map_complex_type_over_dict(self):
|
||||
complex_type = {'minimum_healthy_percent': "75", 'maximum_percent': "150"}
|
||||
type_map = {'minimum_healthy_percent': 'int', 'maximum_percent': 'int'}
|
||||
complex_type_mapped = map_complex_type(complex_type, type_map)
|
||||
complex_type_expected = {'minimum_healthy_percent': 75, 'maximum_percent': 150}
|
||||
self.assertEqual(complex_type_mapped, complex_type_expected)
|
Loading…
Reference in a new issue