PageRenderTime 46ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/test_mysql.py

https://github.com/lgastako/esdb
Python | 71 lines | 63 code | 8 blank | 0 comment | 2 complexity | 66d15a9b3900e68302d0ea3c65af780d MD5 | raw file
  1. import unittest
  2. import MySQLdb
  3. import test_dialects
  4. def get_connection():
  5. conn = MySQLdb.connect(host="localhost",
  6. user="esdb_test",
  7. passwd="esdb_test",
  8. db="esdb_test")
  9. cursor = conn.cursor()
  10. cursor.execute("SET AUTOCOMMIT=0")
  11. return conn
  12. def drop_table_people(db, cursor):
  13. try:
  14. cursor.execute("DROP TABLE people")
  15. db.commit()
  16. except Exception:
  17. pass
  18. def get_create_people_table_ddl():
  19. return """CREATE TABLE people (
  20. id INTEGER PRIMARY KEY,
  21. first_name VARCHAR(255) NOT NULL,
  22. last_name VARCHAR(255) NOT NULL
  23. ) ENGINE=InnoDB"""
  24. class MySQLFunctionTests(test_dialects.FunctionTests):
  25. def get_dialect_connection(self):
  26. return get_connection()
  27. def drop_table_people(self, db, cursor):
  28. return drop_table_people(db, cursor)
  29. def get_create_people_table_ddl(self):
  30. return get_create_people_table_ddl()
  31. class MySQLMethodTests(test_dialects.MethodTests):
  32. def get_dialect_connection(self):
  33. return get_connection()
  34. def drop_table_people(self, db, cursor):
  35. return drop_table_people(db, cursor)
  36. def get_create_people_table_ddl(self):
  37. return get_create_people_table_ddl()
  38. class MySQLMethodTableTests(test_dialects.MethodTableTests):
  39. def get_dialect_connection(self):
  40. return get_connection()
  41. def drop_table_people(self, db, cursor):
  42. return drop_table_people(db, cursor)
  43. def get_create_people_table_ddl(self):
  44. return get_create_people_table_ddl()
  45. if __name__ == '__main__':
  46. unittest.main()