import pytest from ceod.db.MySQLService import MySQLService from ceo_common.errors import DatabaseConnectionError, DatabasePermissionError from mysql.connector import connect from mysql.connector.errors import InterfaceError, ProgrammingError def test_mysql_db_create(cfg): mysql_srv = MySQLService() password = mysql_srv.create_db('test_jdoe') with connect( host=cfg.get('ceod_database_host'), user='test_jdoe', password=password, ) as con: with con.cursor() as cur: cur.execute("SHOW DATABASES") response = cur.fetchall() assert len(response) == 2 mysql_srv.delete_db('test_jdoe') # user should be deleted with pytest.raises(InterfaceError): con = connect( host=cfg.get('ceod_database_host'), user='test_jdoe', password=password, ) def test_mysql_passwd_reset(): pass # test with curl # test with invalid perms for curl # test perms # test with dup user # test with invalid perms for db # test with invalid host for db # except InterfaceError: # raise DatabaseConnectionError() # except ProgrammingError: # raise DatabasePermissionError() # ask for mysql and postgres with proper postgres configs and no public schema # tests are stateless # each test should not require anything before or change anything # this means you should delete user and databases created after done