def test_negative_update(self): c = CounterUpdateClause('a', 4, 7) c.set_context_id(3) self.assertEqual(c.get_context_size(), 1) self.assertEqual(str(c), '"a" = "a" - %(3)s') ctx = {} c.update_context(ctx) self.assertEqual(ctx, {'3': 3})
def noop_update(self): c = CounterUpdateClause('a', 5, 5) c.set_context_id(5) self.assertEqual(c.get_context_size(), 1) self.assertEqual(str(c), '"a" = "a" + %(0)s') ctx = {} c.update_context(ctx) self.assertEqual(ctx, {'5': 0})
def test_positive_update(self): c = CounterUpdateClause('a', 5, 3) c.set_context_id(5) self.assertEqual(c.get_context_size(), 1) self.assertEqual(str(c), '"a" = "a" + %(5)s') ctx = {} c.update_context(ctx) self.assertEqual(ctx, {'5': 2})