~free.ekanayaka/storm/any-expr

« back to all changes in this revision

Viewing changes to tests/databases/base.py

  • Committer: James Henstridge
  • Date: 2009-11-02 12:30:44 UTC
  • mfrom: (329.4.5 storm.bug-387840)
  • Revision ID: james@jamesh.id.au-20091102123044-t5do87h5jd52i09i
Add startswith(), endswith() and contains_string() methods to Comparable.

[r=jkakar,jdo] [f=387840]

Show diffs side-by-side

added added

removed removed

Lines of Context:
395
395
            "UPDATE test SET title='whatever'")
396
396
        self.assertEquals(result.rowcount, 2)
397
397
 
 
398
    def test_expr_startswith(self):
 
399
        self.connection.execute("INSERT INTO test VALUES (30, '!!_%blah')")
 
400
        self.connection.execute("INSERT INTO test VALUES (40, '!!blah')")
 
401
        id = Column("id", SQLToken("test"))
 
402
        title = Column("title", SQLToken("test"))
 
403
        expr = Select(id, title.startswith(u"!!_%"))
 
404
        result = list(self.connection.execute(expr))
 
405
        self.assertEquals(result, [(30,)])
 
406
 
 
407
    def test_expr_endswith(self):
 
408
        self.connection.execute("INSERT INTO test VALUES (30, 'blah_%!!')")
 
409
        self.connection.execute("INSERT INTO test VALUES (40, 'blah!!')")
 
410
        id = Column("id", SQLToken("test"))
 
411
        title = Column("title", SQLToken("test"))
 
412
        expr = Select(id, title.endswith(u"_%!!"))
 
413
        result = list(self.connection.execute(expr))
 
414
        self.assertEquals(result, [(30,)])
 
415
 
 
416
    def test_expr_contains_string(self):
 
417
        self.connection.execute("INSERT INTO test VALUES (30, 'blah_%!!x')")
 
418
        self.connection.execute("INSERT INTO test VALUES (40, 'blah!!x')")
 
419
        id = Column("id", SQLToken("test"))
 
420
        title = Column("title", SQLToken("test"))
 
421
        expr = Select(id, title.contains_string(u"_%!!"))
 
422
        result = list(self.connection.execute(expr))
 
423
        self.assertEquals(result, [(30,)])
 
424
 
398
425
 
399
426
class UnsupportedDatabaseTest(object):
400
427