Example #1
0
    def test_cursor_transactions(self):
        self.db = orm.temp_db('my_test')
        
        self.db.create_table('foo', 'id serial primary key, name varchar(128)')
        self.db.reload()

        c = self.db.cursor(auto_commit=0)
        c2 = self.db.cursor(auto_commit=0)
        
        x = self.db.foo.create()
        x.name = 'graham'

        assert [] == self.db.foo.find()

        x.save(cursor=c)

        assert len(self.db.foo.find(cursor=c)) == 1
        assert len(self.db.foo.find(cursor=c2)) == 0
        
        c.commit()
        
        assert len(self.db.foo.find(cursor=c)) == len(self.db.foo.find(cursor=c2))
Example #2
0
 def setUp(self):
     self.db = orm.temp_db("foo")
     assert self.db.has_no_tables() == True
Example #3
0
import unittest
import time
import orm

import orm.unit_tests
import sys

if orm.unit_tests.db_type == 'sqlite':
    my_db = orm.temp_db('foo')
elif orm.unit_tests.db_type == 'postgres':
    my_db = orm.quick_load('postgres', host='127.0.0.1', user='******', database='orm_test_db')
else:
    my_db = orm.temp_db('foo')
        
class Test_MyTest(unittest.TestCase):
    def setUp(self):
        self.db = my_db
        assert self.db.has_no_tables() == True
                
    def tearDown(self):
        self.db.drop_all_tables()
        assert self.db.has_no_tables() == True