本文整理汇总了Python中stormpath.resources.custom_data.CustomData.save方法的典型用法代码示例。如果您正苦于以下问题:Python CustomData.save方法的具体用法?Python CustomData.save怎么用?Python CustomData.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stormpath.resources.custom_data.CustomData
的用法示例。
在下文中一共展示了CustomData.save方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_saving_does_not_mangle_property_names
# 需要导入模块: from stormpath.resources.custom_data import CustomData [as 别名]
# 或者: from stormpath.resources.custom_data.CustomData import save [as 别名]
def test_saving_does_not_mangle_property_names(self):
props = {
"href": "test/resource",
"foo_with_underscores": 1,
"camelCaseBar": 2,
"baz": {
"baz_value": True,
"bazCamelCase": False,
"quux": ["one", "two", {"value_three": 3, "valueThreeCamel": 3}],
},
}
ds = MagicMock()
client = MagicMock(data_store=ds)
d = CustomData(client, properties=props)
d["another_underscores"] = 3
d["anotherCamelCase"] = 4
d.save()
ds.update_resource.assert_called_once_with(
"test/resource",
{
"foo_with_underscores": 1,
"camelCaseBar": 2,
"another_underscores": 3,
"anotherCamelCase": 4,
"baz": {
"baz_value": True,
"bazCamelCase": False,
"quux": ["one", "two", {"value_three": 3, "valueThreeCamel": 3}],
},
},
)
示例2: test_doesnt_schedule_del_if_new_property
# 需要导入模块: from stormpath.resources.custom_data import CustomData [as 别名]
# 或者: from stormpath.resources.custom_data.CustomData import save [as 别名]
def test_doesnt_schedule_del_if_new_property(self):
ds = MagicMock()
ds.get_resource.return_value = self.props
client = MagicMock(data_store=ds)
d = CustomData(client, properties=self.props)
with self.assertRaises(KeyError):
del d['corge']
d.save()
self.assertFalse(ds.delete_resource.called)
示例3: test_save_empties_delete_list
# 需要导入模块: from stormpath.resources.custom_data import CustomData [as 别名]
# 或者: from stormpath.resources.custom_data.CustomData import save [as 别名]
def test_save_empties_delete_list(self):
ds = MagicMock()
client = MagicMock(data_store=ds)
d = CustomData(client, properties=self.props)
del d['foo']
d.save()
ds.delete_resource.reset_mock()
d.save()
self.assertFalse(ds.delete_resource.called)
示例4: test_del_doesnt_delete_if_new_resource
# 需要导入模块: from stormpath.resources.custom_data import CustomData [as 别名]
# 或者: from stormpath.resources.custom_data.CustomData import save [as 别名]
def test_del_doesnt_delete_if_new_resource(self, is_new):
is_new.return_value = True
ds = MagicMock()
client = MagicMock(data_store=ds)
d = CustomData(client, properties=self.props)
del d['foo']
is_new.return_value = False
d.save()
self.assertFalse(ds.delete_resource.called)
示例5: test_del_then_read_doesnt_set_deleted
# 需要导入模块: from stormpath.resources.custom_data import CustomData [as 别名]
# 或者: from stormpath.resources.custom_data.CustomData import save [as 别名]
def test_del_then_read_doesnt_set_deleted(self):
props = {"href": "test/resource", "bar": "2", "baz": ["one", "two", "three"], "quux": {"key": "value"}}
ds = MagicMock()
ds.get_resource.return_value = self.props
client = MagicMock(data_store=ds)
d = CustomData(client, properties=props)
del d["foo"]
with self.assertRaises(KeyError):
d["foo"]
d.save()
ds.delete_resource.assert_called_once_with("test/resource/foo")
示例6: test_del_delays_deletion_until_save
# 需要导入模块: from stormpath.resources.custom_data import CustomData [as 别名]
# 或者: from stormpath.resources.custom_data.CustomData import save [as 别名]
def test_del_delays_deletion_until_save(self):
ds = MagicMock()
client = MagicMock(data_store=ds)
d = CustomData(client, properties=self.props)
del d['foo']
del d['bar']
self.assertFalse(ds.delete_resource.called)
d.save()
ds.delete_resource.assert_any_call('test/resource/foo')
ds.delete_resource.assert_any_call('test/resource/bar')
self.assertEqual(ds.delete_resource.call_count, 2)
示例7: test_del_then_read_doesnt_set_deleted
# 需要导入模块: from stormpath.resources.custom_data import CustomData [as 别名]
# 或者: from stormpath.resources.custom_data.CustomData import save [as 别名]
def test_del_then_read_doesnt_set_deleted(self):
props = {
'href': 'test/resource',
'bar': '2',
'baz': ['one', 'two', 'three'],
'quux': {'key': 'value'}
}
ds = MagicMock()
ds.get_resource.return_value = self.props
client = MagicMock(data_store=ds)
d = CustomData(client, properties=props)
del d['foo']
with self.assertRaises(KeyError):
d['foo']
d.save()
ds.delete_resource.assert_called_once_with('test/resource/foo')
示例8: test_saving_does_not_mangle_property_names
# 需要导入模块: from stormpath.resources.custom_data import CustomData [as 别名]
# 或者: from stormpath.resources.custom_data.CustomData import save [as 别名]
def test_saving_does_not_mangle_property_names(self):
props = {
'href': 'test/resource',
'foo_with_underscores': 1,
'camelCaseBar': 2,
'baz': {
'baz_value': True,
'bazCamelCase': False,
'quux': [
'one',
'two',
{'value_three': 3, 'valueThreeCamel': 3}
]
}
}
ds = MagicMock()
client = MagicMock(data_store=ds)
d = CustomData(client, properties=props)
d['another_underscores'] = 3
d['anotherCamelCase'] = 4
d.save()
ds.update_resource.assert_called_once_with('test/resource', {
'foo_with_underscores': 1,
'camelCaseBar': 2,
'another_underscores': 3,
'anotherCamelCase': 4,
'baz': {
'baz_value': True,
'bazCamelCase': False,
'quux': [
'one',
'two',
{'value_three': 3, 'valueThreeCamel': 3}
]
}
})