Selaa lähdekoodia

Fix bug in SQLite driver

oz123 10 vuotta sitten
vanhempi
commit
8fba63d3a0
2 muutettua tiedostoa jossa 8 lisäystä ja 6 poistoa
  1. 2 1
      pwman/data/drivers/sqlite.py
  2. 6 5
      pwman/tests/test_sqlite.py

+ 2 - 1
pwman/data/drivers/sqlite.py

@@ -104,7 +104,7 @@ class SQLite(Database):
 
         # create a table to hold DB version info
         self._cur.execute("CREATE TABLE DBVERSION"
-                          "(DB VERSION TEXT NOT NULL DEFAULT '%s')" %
+                          "(VERSION TEXT NOT NULL DEFAULT '%s')" %
                           self.dbformat)
         self._cur.execute("INSERT INTO DBVERSION VALUES('%s')" %
                           self.dbformat)
@@ -202,6 +202,7 @@ class SQLite(Database):
     def removenodes(self, nids):
         sql_rm = "delete from node where id in (%s)" % ','.join('?'*len(nids))
         self._cur.execute(sql_rm, (nids))
+        self._con.commit()
 
     def _clean_orphands(self):
         clean = ("delete from tag where not exists "

+ 6 - 5
pwman/tests/test_sqlite.py

@@ -28,15 +28,17 @@ class TestSQLite(unittest.TestCase):
 
     @classmethod
     def tearDownClass(cls):
+        cls.db.close()
         for item in ('test.db',):
             try:
                 os.remove(item)
             except OSError:
                 continue
 
-    def setUp(self):
-        self.db = SQLite('test.db')
-        self.db._open()
+    @classmethod
+    def setUp(cls):
+        cls.db = SQLite('test.db')
+        cls.db._open()
 
     def test_1_create_tables(self):
         self.db._create_tables()
@@ -132,6 +134,7 @@ class TestSQLite(unittest.TestCase):
         self.db.editnode('2', **node)
 
     def test_9_test_orphands(self):
+        self.db._clean_orphands()
         ce = CryptoEngine.get()
         baz_encrypted = ce.encrypt(u'baz').decode()
 
@@ -157,8 +160,6 @@ class TestSQLite(unittest.TestCase):
         self.db.savekey(ce.get_cryptedkey())
         self.assertEqual(ce.get_cryptedkey(), self.db.loadkey())
 
-    def tearDown(self):
-        self.db.close()
 
 if __name__ == '__main__':