def test_base_attributes(self):
dt = datetime.datetime(1955, 11, 5, 0, 0, tzinfo=iso8601.UTC)
datatime = fields.DateTimeField()
obj = MyObj(self.context)
obj.created_at = dt
obj.updated_at = dt
expected = {'mogan_object.name': 'MyObj',
'mogan_object.namespace': 'mogan',
'mogan_object.version': '1.5',
'mogan_object.changes':
['created_at', 'updated_at'],
'mogan_object.data':
{'created_at': datatime.stringify(dt),
'updated_at': datatime.stringify(dt),
}
}
actual = obj.obj_to_primitive()
# mogan_object.changes is built from a set and order is undefined
self.assertEqual(sorted(expected['mogan_object.changes']),
sorted(actual['mogan_object.changes']))
del expected['mogan_object.changes'], actual['mogan_object.changes']
self.assertEqual(expected, actual)
评论列表
文章目录