本文整理汇总了Python中stormpath.resources.custom_data.CustomData.values方法的典型用法代码示例。如果您正苦于以下问题:Python CustomData.values方法的具体用法?Python CustomData.values怎么用?Python CustomData.values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stormpath.resources.custom_data.CustomData
的用法示例。
在下文中一共展示了CustomData.values方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_custom_data_implements_dict_protocol
# 需要导入模块: from stormpath.resources.custom_data import CustomData [as 别名]
# 或者: from stormpath.resources.custom_data.CustomData import values [as 别名]
def test_custom_data_implements_dict_protocol(self):
d = CustomData(MagicMock(), properties=self.props)
self.assertTrue('created_at' in d)
self.assertTrue('modified_at' in d)
self.assertTrue('foo' in d)
self.assertEqual(d['foo'], 1)
self.assertEqual(d['created_at'], self.created_at)
self.assertEqual(d['modified_at'], self.modified_at)
self.assertEqual(d.get('foo'), 1)
self.assertEqual(d.get('created_at'), self.created_at)
self.assertEqual(d.get('modified_at'), self.modified_at)
self.assertEqual(d.get('nonexistent'), None)
self.assertEqual(d.get('nonexistent', 42), 42)
with self.assertRaises(KeyError):
d['nonexistent']
keys = set(sorted(d.keys(), key=str))
self.assertEqual(keys, set(d))
self.assertEqual(keys, {'created_at', 'modified_at', 'bar', 'baz', 'foo', 'quux'})
values = sorted(list(d.values()), key=str)
keys_from_items = {k for k, v in d.items()}
values_from_items = sorted([v for k, v in d.items()], key=str)
self.assertEqual(keys, keys_from_items)
self.assertEqual(values, values_from_items)