An advantage to using troposphere is being able to unit test various iterations of a dynamic template. However, the lack of support for being able to compare objects with one another makes these test cumbersome to write.
Resolves #1821
What Changed
Added
added .to_json() method to base classes
added .__eq__() and .__ne__() methods to base classes
these use the newly added .to_json() method for comparison of same objects created from the same class to ensure properties are sorted in the same order
comparing against a dict (or list for AWSHelperFn to support Tags) uses .to_dict() instead of converting both to a JSON string
added AWSHelperFn.__hash__()
tests/test_tags.py:TestTags.test_Unsortable was failing with TypeError: unhashable type: 'Sub' without it
Summary
Adds support to compare objects.
Why This Is Needed
An advantage to using troposphere is being able to unit test various iterations of a dynamic template. However, the lack of support for being able to compare objects with one another makes these test cumbersome to write.
Resolves #1821
What Changed
Added
.to_json()
method to base classes.__eq__()
and.__ne__()
methods to base classes.to_json()
method for comparison of same objects created from the same class to ensure properties are sorted in the same orderAWSHelperFn
to supportTags
) uses.to_dict()
instead of converting both to a JSON stringAWSHelperFn.__hash__()
tests/test_tags.py:TestTags.test_Unsortable
was failing withTypeError: unhashable type: 'Sub'
without it