test_mysql.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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) 2015 Oz Nahum Tiram <nahumoz@gmail.com>
  18. # ============================================================================
  19. import unittest
  20. import sys
  21. from .test_crypto_engine import give_key, DummyCallback
  22. if sys.version_info.major > 2: # pragma: no cover
  23. from urllib.parse import urlparse
  24. else: # pragma: no cover
  25. from urlparse import urlparse
  26. import psycopg2 as pg
  27. from pwman.data.drivers.mysql import MySQLDatabase
  28. from pwman.util.crypto_engine import CryptoEngine
  29. class TestPostGresql(unittest.TestCase):
  30. @classmethod
  31. def setUpClass(self):
  32. u = "postgresql://tester:123456@localhost/pwman"
  33. u = urlparse(u)
  34. # password required, for all hosts
  35. # u = "postgresql://<user>:<pass>@localhost/pwman"
  36. self.db = PostgresqlDatabase(u)
  37. self.db._open()
  38. @classmethod
  39. def tearDownClass(self):
  40. self.db._cur.execute("DROP TABLE LOOKUP")
  41. self.db._cur.execute("DROP TABLE TAG")
  42. self.db._cur.execute("DROP TABLE NODE")
  43. self.db._cur.execute("DROP TABLE DBVERSION")
  44. self.db._cur.execute("DROP TABLE CRYPTO")
  45. self.db._con.commit()