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


Python dynamo3.ItemUpdate类代码示例

本文整理汇总了Python中dynamo3.ItemUpdate的典型用法代码示例。如果您正苦于以下问题:Python ItemUpdate类的具体用法?Python ItemUpdate怎么用?Python ItemUpdate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ItemUpdate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_condition_converts_eq_null

 def test_condition_converts_eq_null(self):
     """ Conditional converts eq=None to null=True """
     self.make_table()
     self.dynamo.put_item('foobar', {'id': 'a'})
     update = ItemUpdate.put('foo', set([1, 2]), eq=set())
     self.dynamo.update_item('foobar', {'id': 'a'}, [update])
     update = ItemUpdate.put('foo', set([2]), eq=set())
     with self.assertRaises(CheckFailed):
         self.dynamo.update_item('foobar', {'id': 'a'}, [update])
开发者ID:mnpk,项目名称:dynamo3,代码行数:9,代码来源:test_write.py

示例2: test_atomic_add_set

 def test_atomic_add_set(self):
     """ Update can atomically add to a set """
     self.make_table()
     self.dynamo.put_item('foobar', {'id': 'a'})
     self.dynamo.update_item('foobar', {'id': 'a'},
                             [ItemUpdate.add('foo', set([1]))])
     self.dynamo.update_item('foobar', {'id': 'a'},
                             [ItemUpdate.add('foo', set([1, 2]))])
     item = list(self.dynamo.scan('foobar'))[0]
     self.assertEqual(item, {'id': 'a', 'foo': set([1, 2])})
开发者ID:mnpk,项目名称:dynamo3,代码行数:10,代码来源:test_write.py

示例3: test_atomic_add_num

 def test_atomic_add_num(self):
     """ Update can atomically add to a number """
     self.make_table()
     self.dynamo.put_item('foobar', {'id': 'a'})
     self.dynamo.update_item('foobar', {'id': 'a'},
                             [ItemUpdate.add('foo', 1)])
     self.dynamo.update_item('foobar', {'id': 'a'},
                             [ItemUpdate.add('foo', 2)])
     item = list(self.dynamo.scan('foobar'))[0]
     self.assertEqual(item, {'id': 'a', 'foo': 3})
开发者ID:mnpk,项目名称:dynamo3,代码行数:10,代码来源:test_write.py

示例4: test_expect_condition

 def test_expect_condition(self):
     """ Update can expect a field to meet a condition """
     self.make_table()
     self.dynamo.put_item('foobar', {'id': 'a', 'foo': 5})
     update = ItemUpdate.put('foo', 10, lt=5)
     with self.assertRaises(CheckFailed):
         self.dynamo.update_item('foobar', {'id': 'a'}, [update])
开发者ID:mnpk,项目名称:dynamo3,代码行数:7,代码来源:test_write.py

示例5: test_expect_not_exists_deprecated

 def test_expect_not_exists_deprecated(self):
     """ Update can expect a field to not exist """
     self.make_table()
     self.dynamo.put_item('foobar', {'id': 'a', 'foo': 'bar'})
     update = ItemUpdate.put('foo', 'baz', expected=None)
     with self.assertRaises(CheckFailed):
         self.dynamo.update_item('foobar', {'id': 'a'}, [update])
开发者ID:mnpk,项目名称:dynamo3,代码行数:7,代码来源:test_write.py

示例6: test_expect_condition_or

 def test_expect_condition_or(self):
     """ Expected conditionals can be OR'd together """
     self.make_table()
     self.dynamo.put_item('foobar', {'id': 'a', 'foo': 5})
     update = ItemUpdate.put('foo', 10, lt=5)
     self.dynamo.update_item('foobar', {'id': 'a'}, [update],
                             expect_or=True, baz__null=True)
开发者ID:mnpk,项目名称:dynamo3,代码行数:7,代码来源:test_write.py

示例7: test_expect_field_deprecated

 def test_expect_field_deprecated(self):
     """ Update can expect a field to have a value """
     self.make_table()
     self.dynamo.put_item('foobar', {'id': 'a', 'foo': 'bar'})
     update = ItemUpdate.put('foo', 'baz', expected='wat')
     with self.assertRaises(CheckFailed):
         self.dynamo.update_item('foobar', {'id': 'a'}, [update])
开发者ID:mnpk,项目名称:dynamo3,代码行数:7,代码来源:test_write.py

示例8: test_return_item

 def test_return_item(self):
     """ Update can return the updated item """
     self.make_table()
     self.dynamo.put_item('foobar', {'id': 'a'})
     ret = self.dynamo.update_item('foobar', {'id': 'a'},
                                   [ItemUpdate.put('foo', 'bar')],
                                   returns=ALL_NEW)
     self.assertEqual(ret, {'id': 'a', 'foo': 'bar'})
开发者ID:mnpk,项目名称:dynamo3,代码行数:8,代码来源:test_write.py

示例9: test_delete_field

 def test_delete_field(self):
     """ Update can delete fields from an item """
     self.make_table()
     self.dynamo.put_item('foobar', {'id': 'a', 'foo': 'bar'})
     self.dynamo.update_item('foobar', {'id': 'a'},
                             [ItemUpdate.delete('foo')])
     item = list(self.dynamo.scan('foobar'))[0]
     self.assertEqual(item, {'id': 'a'})
开发者ID:mnpk,项目名称:dynamo3,代码行数:8,代码来源:test_write.py

示例10: test_update_field

 def test_update_field(self):
     """ Update an item field """
     self.make_table()
     self.dynamo.put_item('foobar', {'id': 'a'})
     self.dynamo.update_item('foobar', {'id': 'a'},
                             [ItemUpdate.put('foo', 'bar')])
     item = list(self.dynamo.scan('foobar'))[0]
     self.assertEqual(item, {'id': 'a', 'foo': 'bar'})
开发者ID:mnpk,项目名称:dynamo3,代码行数:8,代码来源:test_write.py

示例11: test_write_converts_none

 def test_write_converts_none(self):
     """ Write operation converts None values to a DELETE """
     hash_key = DynamoKey('id', data_type=STRING)
     self.dynamo.create_table('foobar', hash_key=hash_key)
     self.dynamo.put_item('foobar', {'id': 'a', 'foo': 'bar'})
     update = ItemUpdate.put('foo', None)
     self.dynamo.update_item('foobar', {'id': 'a'}, [update])
     ret = list(self.dynamo.scan('foobar'))
     self.assertItemsEqual(ret, [{'id': 'a'}])
开发者ID:mnpk,项目名称:dynamo3,代码行数:9,代码来源:test_write.py

示例12: test_sync_only_updates_changed

    def test_sync_only_updates_changed(self):
        """ Sync only updates fields that have been changed """
        with patch.object(self.engine, 'dynamo') as dynamo:
            captured_updates = []

            def update_item(_, __, updates, *___, **____):
                """ Mock update_item and capture the passed updateds """
                captured_updates.extend(updates)
                return {}
            dynamo.update_item.side_effect = update_item

            p = Post('a', 'b', 4)
            self.engine.save(p)
            p.foobar = set('a')
            p.points = Decimal('2')
            p.sync(raise_on_conflict=False)
            self.assertEqual(len(captured_updates), 2)
            self.assertTrue(ItemUpdate.put('foobar', ANY) in captured_updates)
            self.assertTrue(ItemUpdate.put('points', ANY) in captured_updates)
开发者ID:numberoverzero,项目名称:flywheel,代码行数:19,代码来源:test_models.py

示例13: test_return_metadata

 def test_return_metadata(self):
     """ The Update return value contains capacity metadata """
     self.make_table()
     self.dynamo.put_item('foobar', {'id': 'a'})
     ret = self.dynamo.update_item('foobar', {'id': 'a'},
                                   [ItemUpdate.put('foo', 'bar')],
                                   returns=ALL_NEW,
                                   return_capacity=TOTAL)
     self.assertTrue(is_number(ret.capacity))
     self.assertTrue(is_number(ret.table_capacity))
     self.assertTrue(isinstance(ret.indexes, dict))
     self.assertTrue(isinstance(ret.global_indexes, dict))
开发者ID:mnpk,项目名称:dynamo3,代码行数:12,代码来源:test_write.py

示例14: test_item_update_eq

 def test_item_update_eq(self):
     """ ItemUpdates should be equal """
     a, b = ItemUpdate.put('foo', 'bar'), ItemUpdate.put('foo', 'bar')
     self.assertEqual(a, b)
     self.assertEqual(hash(a), hash(b))
     self.assertFalse(a != b)
开发者ID:mnpk,项目名称:dynamo3,代码行数:6,代码来源:test_write.py

示例15: test_write_add_require_value

 def test_write_add_require_value(self):
     """ Doing an ADD requires a non-null value """
     with self.assertRaises(ValueError):
         ItemUpdate.add('foo', None)
开发者ID:mnpk,项目名称:dynamo3,代码行数:4,代码来源:test_write.py


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