test_sqlite.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #============================================================================
  2. # This file is part of Pwman3.
  3. #
  4. # Pwman3 is free software; you can redistribute iut and/or modify
  5. # it under the terms of the GNU General Public License, version 2
  6. # as published by the Free Software Foundation;
  7. #
  8. # Pwman3 is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with Pwman3; if not, write to the Free Software
  15. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. #============================================================================
  17. # Copyright (C) 2012 Oz Nahum Tiram <nahumoz@gmail.com>
  18. #============================================================================
  19. import os
  20. import unittest
  21. from pwman.data.drivers.sqlite import SQLite
  22. class TestSQLite(unittest.TestCase):
  23. def setUp(self):
  24. self.db = SQLite('test.db')
  25. self.db._open()
  26. def test_1_create_tables(self):
  27. self.db._create_tables()
  28. self.db._con.commit()
  29. # the method _open calls _create_tables
  30. self.db.save_crypto_info("foo", "bar")
  31. def test_2_crypto_info(self):
  32. self.db.save_crypto_info("foo", "bar")
  33. f = self.db.fetch_crypto_info()
  34. self.assertListEqual([u'foo', u'bar'], list(f))
  35. if __name__ == '__main__':
  36. try:
  37. unittest.main(verbosity=2)
  38. except SystemExit:
  39. os.remove('test.db')