test_objects.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:mogan 作者: openstack 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号