~edoardo-serra/storm/select-for-update-support

« back to all changes in this revision

Viewing changes to tests/expr.py

  • Committer: Edoardo Serra
  • Date: 2010-09-08 18:56:43 UTC
  • Revision ID: eserra@barbera-20100908185643-z4lnntw6ry8425dr
Unit tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
        self.assertEquals(expr.limit, Undef)
66
66
        self.assertEquals(expr.offset, Undef)
67
67
        self.assertEquals(expr.distinct, False)
 
68
        self.assertEquals(expr.having, Undef)
 
69
        self.assertEquals(expr.for_update, False)
68
70
 
69
71
    def test_select_constructor(self):
70
 
        objects = [object() for i in range(9)]
 
72
        objects = [object() for i in range(11)]
71
73
        expr = Select(*objects)
72
74
        self.assertEquals(expr.columns, objects[0])
73
75
        self.assertEquals(expr.where, objects[1])
78
80
        self.assertEquals(expr.limit, objects[6])
79
81
        self.assertEquals(expr.offset, objects[7])
80
82
        self.assertEquals(expr.distinct, objects[8])
 
83
        self.assertEquals(expr.having, objects[9])
 
84
        self.assertEquals(expr.for_update, objects[10])
81
85
 
82
86
    def test_insert_default(self):
83
87
        expr = Insert(None)
657
661
                          'SELECT DISTINCT column1, column2 FROM "table 1"')
658
662
        self.assertEquals(state.parameters, [])
659
663
 
 
664
    def test_select_for_update(self):
 
665
        expr = Select([column1, column2], Undef, [table1], for_update=True)
 
666
        state = State()
 
667
        statement = compile(expr, state)
 
668
        self.assertEquals(statement,
 
669
                          'SELECT column1, column2 FROM "table 1" FOR UPDATE')
 
670
        self.assertEquals(state.parameters, [])
 
671
 
660
672
    def test_select_where(self):
661
673
        expr = Select([column1, Func1()],
662
674
                      Func1(),