ironic/ironic/tests/unit
Mark Goddard c66679f14b Support nested objects and object lists in as_dict
The value returned by ironic.objects.IronicObject.as_dict() should be a
plain object, in order for it to be serialised to JSON. Currently,
nested object fields and object list fields are not converted to dict
format. This caused problems during cleaning, when the node object's
as_dict representation is JSON encoded and sent to IPA.

This change adds support for calling as_dict() on nested objects and
list objects, to ensure these are also returned in dict form.

We also change the method used in as_dict() for checking whether an
object has an attribute. The hasattr() function used previously has
problems when used with properties in python 2 [1], in that any
exceptions raised in the property getter result in hasattr() returning
False. Instead we use obj_attr_is_set() to determine whether the object
has a particular attribute.

[1] https://hynek.me/articles/hasattr/

Change-Id: Ib2166040508827db28d6f6e2d9a3e655c16f2993
Closes-Bug: #1750027
2018-02-22 00:29:58 +00:00
..
api Fix rare HTTP 400 from port list API 2018-02-16 17:20:19 +01:00
cmd Allow data migrations to accept options 2018-01-25 16:51:42 +00:00
common Merge "Remove test_contains_current_release_entry" 2018-02-15 16:52:46 +00:00
conductor Merge "Clean nodes stuck in CLEANING state when ir-cond restarts" 2018-02-19 17:17:50 +00:00
conf Remove legacy auth loading 2017-06-06 10:20:54 +00:00
db Merge "Conductor version cannot be null in Rocky" 2018-02-19 17:17:39 +00:00
dhcp Use adapters for neutronclient 2017-12-14 13:36:03 +02:00
drivers Merge "Add validate_rescue() method to boot interface" 2018-02-13 05:00:38 +00:00
objects Support nested objects and object lists in as_dict 2018-02-22 00:29:58 +00:00
__init__.py Setup logging in unit tests 2017-04-13 20:47:10 +03:00
policy_fixture.py Add keystone policy support to Ironic 2016-08-04 12:43:20 +00:00
raid_constants.py RAID interface to support JBOD volumes 2016-05-04 14:28:48 +00:00
stubs.py Handle case when a glance image contains no data 2018-02-07 13:45:55 +01:00