当前位置: 首页>>代码示例>>Python>>正文


Python CustomData.save方法代码示例

本文整理汇总了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}],
                },
            },
        )
开发者ID:lusis,项目名称:stormpath-sdk-python,代码行数:35,代码来源:test_custom_data.py

示例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)
开发者ID:ecrisostomo,项目名称:stormpath-sdk-python,代码行数:12,代码来源:test_custom_data.py

示例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)
开发者ID:ecrisostomo,项目名称:stormpath-sdk-python,代码行数:12,代码来源:test_custom_data.py

示例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)
开发者ID:ecrisostomo,项目名称:stormpath-sdk-python,代码行数:12,代码来源:test_custom_data.py

示例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")
开发者ID:lusis,项目名称:stormpath-sdk-python,代码行数:14,代码来源:test_custom_data.py

示例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)
开发者ID:ecrisostomo,项目名称:stormpath-sdk-python,代码行数:15,代码来源:test_custom_data.py

示例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')
开发者ID:ecrisostomo,项目名称:stormpath-sdk-python,代码行数:19,代码来源:test_custom_data.py

示例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}
                ]
            }
        })
开发者ID:stormpath,项目名称:stormpath-sdk-python,代码行数:40,代码来源:test_custom_data.py


注:本文中的stormpath.resources.custom_data.CustomData.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。