Oz N Tiram 8 лет назад
Родитель
Сommit
43b318beef
2 измененных файлов с 8 добавлено и 10 удалено
  1. 3 3
      pwman/ui/cli.py
  2. 5 7
      tests/test_sqlite.py

+ 3 - 3
pwman/ui/cli.py

@@ -36,12 +36,12 @@ except ImportError as e:  # pragma: no cover
 
 
 from pwman.ui.baseui import BaseCommands
-from pwman import (get_conf_options, get_db_version, version, website, parser_options)  # noqa
+from pwman import (get_conf_options, get_db_version, version, website,
+                   parser_options, has_cryptography)
 from pwman.ui.tools import CLICallback
 from pwman.data import factory
 from pwman.exchange.importer import Importer
 from pwman.util.crypto_engine import CryptoEngine
-import pwman.util
 
 
 class PwmanCli(cmd.Cmd, BaseCommands):
@@ -100,7 +100,7 @@ def main():
     xselpath, dbtype, config = get_conf_options(args, OSX)
     dburi = config.get_value('Database', 'dburi')
 
-    if not pwman.util.has_cryptography:
+    if not has_cryptography:
         import colorama
         if config.get_value('Crypto', 'supress_warning').lower() != 'yes':
             print("{}WARNING: You are not using PyCrypto!!!\n"

+ 5 - 7
tests/test_sqlite.py

@@ -58,17 +58,15 @@ class TestSQLite(unittest.TestCase):
 
     def test_3_add_node(self):
         node = Node(clear_text=True,
-                    **{'username': u"alice", 'password': u"secret",
-                       'url': u"wonderland.com",
-                       'notes': u"a really great place",
-                       'tags': [u'foo', u'bar']})
+                    **{'username': "alice", 'password': "secret",
+                       'url': "wonderland.com",
+                       'notes': "a really great place",
+                       'tags': ['foo', 'bar']})
         self.db.add_node(node)
         rv = self.db._cur.execute("select * from node")
-        # clearly this fails, while alice is not found in clear text in the
-        # database!
         ce = CryptoEngine.get()
         res = rv.fetchone()
-        self.assertIn(ce.encrypt(u'alice'), res[1])
+        self.assertEqual(ce.decrypt(res[1]), b"alice")
 
     def test_4_test_tags(self):
         node = Node(clear_text=True,