db_tests.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import os
  2. import os.path
  3. _saveconfig = True
  4. import sys
  5. if 'darwin' in sys.platform:
  6. from pwman.ui.mac import PwmanCliMac as PwmanCli
  7. from pwman.ui.mac import PwmanCliMacNew as PwmanCliNew
  8. OSX = True
  9. elif 'win' in sys.platform:
  10. from pwman.ui.cli import PwmanCli
  11. from pwman.ui.win import PwmanCliWinNew as PwmanCliNew
  12. OSX = False
  13. else:
  14. from pwman.ui.cli import PwmanCli
  15. from pwman.ui.cli import PwmanCliNew
  16. OSX = False
  17. import pwman.util.config as config
  18. import pwman.data.factory
  19. from pwman.data.convertdb import PwmanConvertDB
  20. # set cls_timout to negative number (e.g. -1) to disable
  21. default_config = {'Global': {'umask': '0100', 'colors': 'yes',
  22. 'cls_timeout': '5'
  23. },
  24. 'Database': {'type': 'SQLite',
  25. 'filename': os.path.join("tests", "pwman.db")},
  26. 'Encryption': {'algorithm': 'AES'},
  27. 'Readline': {'history': os.path.join("tests",
  28. "history")}
  29. }
  30. config.set_defaults(default_config)
  31. import unittest
  32. class DBTests(unittest.TestCase):
  33. """test everything related to db"""
  34. def test(self):
  35. self.assertTrue(True)
  36. def test_db_created(self):
  37. "test that the right db instance was created"
  38. dbver = 0.4
  39. dbtype = config.get_value("Database", "type")
  40. db = pwman.data.factory.create(dbtype, dbver)
  41. self.assertIn(dbtype, db.__class__.__name__)
  42. class CLITests(unittest.TestCase):
  43. """test command line functionallity"""
  44. def test(self):
  45. self.assertTrue(True)