فهرست منبع

improve testing

oz123 11 سال پیش
والد
کامیت
dcdde54066
3فایلهای تغییر یافته به همراه18 افزوده شده و 9 حذف شده
  1. 14 6
      pwman/tests/db_tests.py
  2. 2 1
      pwman/tests/test_pwman.py
  3. 2 2
      pwman/ui/cli.py

+ 14 - 6
pwman/tests/db_tests.py

@@ -114,12 +114,20 @@ class DBTests(unittest.TestCase):
         got_tags = self.tester.cli._tags(enc)
         self.assertEqual(2, len(got_tags))
 
+
+class CLITests(unittest.TestCase):
+    """
+    test command line functionallity
+    """
+
+    def setUp(self):
+        "test that the right db instance was created"
+        dbver = 0.4
+        self.dbtype = config.get_value("Database", "type")
+        self.db = pwman.data.factory.create(self.dbtype, dbver)
+        self.tester = SetupTester()
+        self.tester.create()
+
     def test_input(self):
         name = self.tester.cli.get_username(reader=lambda: 'alice')
         self.assertEqual(name, 'alice')
-
-
-class CLITests(unittest.TestCase):
-    """test command line functionallity"""
-    def test(self):
-        self.assertTrue(True)

+ 2 - 1
pwman/tests/test_pwman.py

@@ -22,7 +22,7 @@
 import os
 import sys
 import unittest
-from db_tests import (DBTests, SetupTester)
+from db_tests import (DBTests, SetupTester, CLITests)
 from crypto_tests import CryptoTest
 
 # make sure we use local pwman
@@ -38,6 +38,7 @@ def suite():
     suite = unittest.TestSuite()
     suite.addTest(loader.loadTestsFromTestCase(DBTests))
     suite.addTest(loader.loadTestsFromTestCase(CryptoTest))
+    suite.addTest(loader.loadTestsFromTestCase(CLITests))
     return suite
 
 if __name__ == '__main__':

+ 2 - 2
pwman/ui/cli.py

@@ -88,8 +88,8 @@ class PwmanCliOld(cmd.Cmd, HelpUI, BaseUI):
                              int(m.group(2)) + 1)
         return ids
 
-    def get_filesystem_path(self, default=""):
-        return tools.getinput("Enter filename: ", default)
+    def get_filesystem_path(self, default="", reader=raw_input):
+        return tools.getinput("Enter filename: ", default, reader=reader)
 
     def get_username(self, default="", reader=raw_input):
         return tools.getinput("Username: ", default, reader)