Ejemplo n.º 1
0
    def test_add_str(self):
        op_1 = operation.UpdateOperation(TestTable,
                                         'hello',
                                         delete={'my_name': None},
                                         add={'count': "hello "})
        op_2 = operation.UpdateOperation(TestTable,
                                         'hello',
                                         delete={'my_name': None},
                                         add={'count': "world"})

        full_op = op_1.combine_updates(op_2)

        assert_equal(full_op.delete['my_name'], None)
        assert_equal(full_op.add['count'], "hello world")
Ejemplo n.º 2
0
    def test_add_count(self):
        op_1 = operation.UpdateOperation(TestTable,
                                         'hello',
                                         put={'my_name': 'slim shady'},
                                         add={'count': 1})
        op_2 = operation.UpdateOperation(TestTable,
                                         'hello',
                                         put={'my_name': 'slim shady'},
                                         add={'count': 4})

        full_op = op_1.combine_updates(op_2)

        assert_equal(full_op.put['my_name'], 'slim shady')
        assert_equal(full_op.add['count'], 5)
Ejemplo n.º 3
0
            def have_result(self, op_results, op_cb):
                super(ByTwoOperation, self).have_result(op_results, op_cb)

                # return an equivalent update operation
                op_results.next_ops.append(
                    operation.UpdateOperation(self.table,
                                              self.key,
                                              add=self.add))
Ejemplo n.º 4
0
 def remove(self, entity):
     return [
         operation.UpdateOperation(
             TestTable,
             "__totals__",
             put={'type': 'counter'},
             add={'%s_count' % entity['type']: -entity['count']})
     ]
Ejemplo n.º 5
0
 def build_op(self):
     self.op = operation.UpdateOperation(TestTable,
                                         'hello',
                                         put={'my_name': 'slim shady'},
                                         add={'count': 1})
     self.results = operation.OperationResult(self.db)
Ejemplo n.º 6
0
 def build_operation(self):
     self.op = operation.UpdateOperation(TestTable,
                                         self.entity['key'],
                                         add={'count': 1})
     self.results = operation.OperationResult(self.db)
Ejemplo n.º 7
0
 def remove(cls, op, result):
     return [
         operation.UpdateOperation(cls.view_table, result['value'],
                                   {'count': -1})
     ]
Ejemplo n.º 8
0
 def add(cls, op, result):
     entity = op.entity
     return [
         operation.UpdateOperation(cls.view_table, entity['value'],
                                   {'count': 1})
     ]