provide tests.util package, starting with setup_logging()
This commit is contained in:
parent
9f0eaa8675
commit
ec97d4f82b
5 changed files with 18 additions and 9 deletions
|
@ -43,6 +43,6 @@ oidc_params = dict(
|
||||||
cookie_crypt=getenv('OIDC_COOKIE_CRYPT', None),
|
cookie_crypt=getenv('OIDC_COOKIE_CRYPT', None),
|
||||||
private_key_file=getenv('OIDC_SERVICE_USER_PRIVATE_KEY_FILE', '.private-key.json'),
|
private_key_file=getenv('OIDC_SERVICE_USER_PRIVATE_KEY_FILE', '.private-key.json'),
|
||||||
organization_id=getenv('OIDC_ORGANIZATION_ID', '12346'),
|
organization_id=getenv('OIDC_ORGANIZATION_ID', '12346'),
|
||||||
project_id=getenv('OIDC_PROJECT_ID', '12347'),
|
project_id=getenv('OIDC_PROJECT_ID', None),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -11,14 +11,6 @@ log_level = logging.INFO
|
||||||
log_format = '%(asctime)s %(levelname)s %(name)s %(message)s'
|
log_format = '%(asctime)s %(levelname)s %(name)s %(message)s'
|
||||||
log_dateformat = '%Y-%m-%dT%H:%M:%S'
|
log_dateformat = '%Y-%m-%dT%H:%M:%S'
|
||||||
|
|
||||||
def setup_logging():
|
|
||||||
hdlr = logging.getLogger().handlers[-1]
|
|
||||||
logging.getLogger().removeHandler(hdlr) # remove NullHandler added by testrunner
|
|
||||||
logging.basicConfig(filename=log_file, level=log_level,
|
|
||||||
format=log_format, datefmt=log_dateformat)
|
|
||||||
|
|
||||||
setup_logging()
|
|
||||||
|
|
||||||
# server / app settings
|
# server / app settings
|
||||||
server_port = '8999'
|
server_port = '8999'
|
||||||
base_url = 'testing:'
|
base_url = 'testing:'
|
||||||
|
|
|
@ -8,8 +8,11 @@ sys.path = [os.path.dirname(__file__)] + sys.path
|
||||||
import unittest
|
import unittest
|
||||||
from scopes.tests import tlib_storage
|
from scopes.tests import tlib_storage
|
||||||
|
|
||||||
|
from scopes.tests.util import setup_logging
|
||||||
from scopes.storage.db.postgres import StorageFactory
|
from scopes.storage.db.postgres import StorageFactory
|
||||||
import config
|
import config
|
||||||
|
setup_logging(config)
|
||||||
|
|
||||||
config.dbengine = 'postgresql+psycopg'
|
config.dbengine = 'postgresql+psycopg'
|
||||||
config.dbname = 'testdb'
|
config.dbname = 'testdb'
|
||||||
config.dbuser = 'testuser'
|
config.dbuser = 'testuser'
|
||||||
|
|
|
@ -8,8 +8,11 @@ sys.path = [os.path.dirname(__file__)] + sys.path
|
||||||
import unittest
|
import unittest
|
||||||
from scopes.tests import tlib_web, tlib_storage
|
from scopes.tests import tlib_web, tlib_storage
|
||||||
|
|
||||||
|
from scopes.tests.util import setup_logging
|
||||||
from scopes.storage.common import StorageFactory
|
from scopes.storage.common import StorageFactory
|
||||||
import config
|
import config
|
||||||
|
setup_logging(config)
|
||||||
|
|
||||||
config.dbengine = 'sqlite'
|
config.dbengine = 'sqlite'
|
||||||
config.dbname = 'var/test.db'
|
config.dbname = 'var/test.db'
|
||||||
config.dbschema = None
|
config.dbschema = None
|
||||||
|
|
11
scopes/tests/util.py
Normal file
11
scopes/tests/util.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# scopes.tests.util
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
def setup_logging(config):
|
||||||
|
hdlr = logging.getLogger().handlers[-1]
|
||||||
|
logging.getLogger().removeHandler(hdlr) # remove NullHandler added by testrunner
|
||||||
|
logging.basicConfig(filename=config.log_file, level=config.log_level,
|
||||||
|
format=config.log_format, datefmt=config.log_dateformat)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue