Beispiel #1
0
    def testDBPropertyFileDoesNotExist(self):
        import os.path
        f = 'foo.db'

        self.sqlite = SQLiteConnection()
        self.sqlite.database = f
        self.assertEqual(os.path.isfile(self.sqlite.database), False)
Beispiel #2
0
 def testDBPropertyFileExists(self):
     import os.path
     self.sqlite = SQLiteConnection()
     self.sqlite.database = FILENAME
     self.assertEqual(os.path.isfile(self.sqlite.database), True)
Beispiel #3
0
 def testDBPropertyIsNone(self):
     self.sqlite = SQLiteConnection()
     self.sqlite.database = None
     self.assertEqual(self.sqlite.database, None)
Beispiel #4
0
 def testDBPropertyIsMemory(self):
     self.sqlite = SQLiteConnection()
     self.sqlite.database = ':memory:'
     self.assertEqual(self.sqlite.database, ':memory:')
Beispiel #5
0
 def testDatabaseIsMemory(self):
     self.sqlite = SQLiteConnection(database=':memory:')
     self.assertEqual(self.sqlite.database, ':memory:')
Beispiel #6
0
 def testAutoCommitInTypes(self):
     self.sqlite = SQLiteConnection(autocommit=None)
     self.assertTrue(self.sqlite.autocommit in
             self.sqlite._autocommit_levels)
Beispiel #7
0
 def testDatabaseIsNone(self):
     self.sqlite = SQLiteConnection(database=None)
     self.assertEqual(self.sqlite.database, None)
Beispiel #8
0
class TestSQLiteConnection(unittest.TestCase):

    # database from __init__
    def testDatabaseIsNone(self):
        self.sqlite = SQLiteConnection(database=None)
        self.assertEqual(self.sqlite.database, None)

    def testDatabaseIsMemory(self):
        self.sqlite = SQLiteConnection(database=':memory:')
        self.assertEqual(self.sqlite.database, ':memory:')

    def testDatabaseFileExists(self):
        import os.path
        self.sqlite = SQLiteConnection(database=FILENAME)
        self.assertEqual(os.path.isfile(self.sqlite.database), True)

    def testDatabaseFileDoesNotExist(self):
        import os.path
        f = 'foo.db'
        self.sqlite = SQLiteConnection(database=f)
        self.assertEqual(os.path.isfile(self.sqlite.database), False)

    # autocommit in __init__
    def testAutoCommitInTypes(self):
        self.sqlite = SQLiteConnection(autocommit=None)
        self.assertTrue(self.sqlite.autocommit in
                self.sqlite._autocommit_levels)


    # database as property
    def testDBPropertyIsNone(self):
        self.sqlite = SQLiteConnection()
        self.sqlite.database = None
        self.assertEqual(self.sqlite.database, None)

    def testDBPropertyIsMemory(self):
        self.sqlite = SQLiteConnection()
        self.sqlite.database = ':memory:'
        self.assertEqual(self.sqlite.database, ':memory:')

    def testDBPropertyFileExists(self):
        import os.path
        self.sqlite = SQLiteConnection()
        self.sqlite.database = FILENAME
        self.assertEqual(os.path.isfile(self.sqlite.database), True)

    def testDBPropertyFileDoesNotExist(self):
        import os.path
        f = 'foo.db'

        self.sqlite = SQLiteConnection()
        self.sqlite.database = f
        self.assertEqual(os.path.isfile(self.sqlite.database), False)


    # autocommit
    def testAutoCommitNotInTypes(self):
        with self.assertRaises(ValueError):
            self.sqlite = SQLiteConnection()
            self.sqlite.autocommit = 'FOO'

    
    # connect
    def testConnectDatabaseNotSet(self):
        self.sqlite = SQLiteConnection()
        with self.assertRaises(ValueError):
            self.sqlite.connect()

    def testConnect(self):
        self.sqlite = SQLiteConnection()
        self.sqlite.database = FILENAME
        db = self.sqlite.connect
        self.assertTrue('sqlite3.Connection' in repr(db))
        db.close()
Beispiel #9
0
 def testConnect(self):
     self.sqlite = SQLiteConnection()
     self.sqlite.database = FILENAME
     db = self.sqlite.connect
     self.assertTrue('sqlite3.Connection' in repr(db))
     db.close()
Beispiel #10
0
 def testConnectDatabaseNotSet(self):
     self.sqlite = SQLiteConnection()
     with self.assertRaises(ValueError):
         self.sqlite.connect()
Beispiel #11
0
 def testAutoCommitNotInTypes(self):
     with self.assertRaises(ValueError):
         self.sqlite = SQLiteConnection()
         self.sqlite.autocommit = 'FOO'