Przeglądaj źródła

Add lookup functionality and test coverage for it

Oz Nahum Tiram 10 lat temu
rodzic
commit
e6874ca0d2
2 zmienionych plików z 9 dodań i 3 usunięć
  1. 3 2
      pwman/data/drivers/sqlite.py
  2. 6 1
      pwman/tests/test_sqlite.py

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

@@ -14,7 +14,7 @@
 # along with Pwman3; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #============================================================================
-# Copyright (C) 2012 Oz Nahum <nahumoz@gmail.com>
+# Copyright (C) 2012, 2013, 2014 Oz Nahum Tiram <nahumoz@gmail.com>
 #============================================================================
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 #============================================================================
@@ -436,7 +436,8 @@ class SQLite(SQLiteDatabaseNewForm):
             return self._cur.lastrowid
 
     def _update_tag_lookup(self, nodeid, tid):
-        pass
+        sql_lookup = "INSERT INTO LOOKUP(nodeid, tagid) VALUES(?,?)"
+        self._cur.execute(sql_lookup, (nodeid, tid))
 
     def _setnodetags(self, nodeid, tags):
         for tag in tags:

+ 6 - 1
pwman/tests/test_sqlite.py

@@ -14,7 +14,7 @@
 # along with Pwman3; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #============================================================================
-# Copyright (C) 2012 Oz Nahum Tiram <nahumoz@gmail.com>
+# Copyright (C) 2012, 2013, 2014 Oz Nahum Tiram <nahumoz@gmail.com>
 #============================================================================
 import os
 import unittest
@@ -68,6 +68,11 @@ class TestSQLite(unittest.TestCase):
         self.db._get_or_create_tag(node._tags[0])
         self.assertEqual(1, self.db._get_or_create_tag(node._tags[0]))
         self.assertEqual(3, self.db._get_or_create_tag(ce.encrypt('baz')))
+    
+    def test_5_test_lookup(self):
+        self.db._cur.execute('SELECT * FROM LOOKUP')
+        rows = self.db._cur.fetchall()
+        self.assertEqual(2, len(rows))
 
     def tearDown(self):
         self.db.close()