32 lines
865 B
Python
32 lines
865 B
Python
#!/usr/bin/env python3
|
|
|
|
import logging
|
|
|
|
import pytest
|
|
|
|
import config
|
|
from pydb import DatabaseManager
|
|
|
|
fmt = "[%(asctime)s] |%(name)s|%(levelname)s|%(message)s|"
|
|
formatter = logging.Formatter(fmt)
|
|
handler = logging.StreamHandler()
|
|
handler.setFormatter(formatter)
|
|
logger = logging.getLogger(__name__)
|
|
logger.setLevel(logging.DEBUG)
|
|
logger.addHandler(handler)
|
|
|
|
|
|
def test_mysql():
|
|
with DatabaseManager(config.MYSQL_INFO, "mysql", dictionary=True) as db:
|
|
res = db.query("SELECT * FROM dir_map WHERE source_dir = 'aho-girl'")
|
|
logger.info("Result: %s", res)
|
|
# print("Result: ", res)
|
|
assert res is not None and len(res) > 0
|
|
|
|
|
|
def test_mysql_2():
|
|
db = DatabaseManager(config.MYSQL_INFO, "mysql").__enter__()
|
|
res = db.query("SELECT COUNT(*) FROM dir_map")
|
|
logger.info("Result: %s", res)
|
|
assert res is not None and res > 0
|