Przeglądaj źródła

Some more testing for baseui

 * Add task improving the sqlite driver
oz123 10 lat temu
rodzic
commit
eec4f713b2
3 zmienionych plików z 17 dodań i 3 usunięć
  1. 5 1
      pwman/data/drivers/sqlite.py
  2. 8 2
      pwman/tests/test_base_ui.py
  3. 4 0
      pwman/ui/baseui.py

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

@@ -475,7 +475,11 @@ class SQLite(SQLiteDatabaseNewForm):
             self._update_tag_lookup(nodeid, tid)
 
     def getnodes(self, ids):
-        """get nodes as raw ciphertext"""
+        """
+        get nodes as raw ciphertext
+        """
+        # TODO: getnodes currently returns only nodes, what about their tags?
+        # This method should return the tags too ...
         sql = "SELECT * FROM NODE WHERE ID IN (%s)" % ','.join('?'*len(ids))
         self._cur.execute(sql, (ids))
         nodes = self._cur.fetchall()

+ 8 - 2
pwman/tests/test_base_ui.py

@@ -49,8 +49,14 @@ class TestBaseUI(unittest.TestCase):
         sys.stdin = sys.__stdin__
 
     def test_do_newn(self):
-        sys.stdin = StringIO("foo\nbar\nbaz\n")
-        self.tester.cli.do_newn('')
+        sys.stdin = StringIO(("alice\nsecret\nexample.com\nsome notes"
+                              "\nfoo bar baz"))
+        _node = self.tester.cli.do_newn('')
+        self.assertListEqual(['foo', 'bar', 'baz'], _node.tags)
+        sys.stdin = sys.__stdin__
+        nodeid = self.tester.cli._db.listnodes()
+        self.assertListEqual([1], nodeid)
+        nodes = self.tester.cli._db.getnodes(nodeid)
 
 
 if __name__ == '__main__':

+ 4 - 0
pwman/ui/baseui.py

@@ -107,9 +107,12 @@ class BaseCommands(HelpUI):
                 node[2],
                 'yyyyy',
                 []))
+        # TOOD: after geting the nodes,
+        #       one needs to get their prospective tags
         for node in _nodes_inst:
             print(node)
 
+
     def do_filter(self, args):
         pass
 
@@ -135,3 +138,4 @@ class BaseCommands(HelpUI):
         node['tags'] = self._get_tags()
         node = Node(clear_text=True, **node)
         self._db.add_node(node)
+        return node