From ba37784ba5be2e1e75610acdf33b70bc34fa4175 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Fri, 20 Apr 2018 12:17:39 +0200 Subject: [PATCH 1/2] tests: use sql_mode publisher creation in test_sql --- tests/test_sql.py | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/tests/test_sql.py b/tests/test_sql.py index f8395140..fd9a84aa 100644 --- a/tests/test_sql.py +++ b/tests/test_sql.py @@ -19,7 +19,7 @@ from wcs.wf.jump import JumpWorkflowStatusItem from wcs import sql import wcs.qommon.storage as st -from utilities import create_temporary_pub +from utilities import create_temporary_pub, clean_temporary_pub import pytest postgresql = pytest.mark.postgresql @@ -34,19 +34,7 @@ def setup_module(module): cleanup() - pub = create_temporary_pub() - pub.user_class = sql.SqlUser - pub.is_using_postgresql = lambda: True - - conn = psycopg2.connect(user=os.environ['USER']) - conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT) - cur = conn.cursor() - dbname = 'wcstests%d' % random.randint(0, 100000) - cur.execute('CREATE DATABASE %s' % dbname) - cur.close() - - pub.cfg['postgresql'] = {'database': dbname, 'user': os.environ['USER']} - pub.initialize_sql() + pub = create_temporary_pub(sql_mode=True) formdef = formdef.FormDef() formdef.name = 'tests' @@ -61,20 +49,8 @@ def setup_module(module): ] formdef.store() - conn.close() - - def teardown_module(module): - shutil.rmtree(pub.APP_DIR) - - if hasattr(pub, 'pgconn') and pub.pgconn: - pub.pgconn.close() - - conn = psycopg2.connect(user=os.environ['USER']) - conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT) - cur = conn.cursor() - cur.execute('DROP DATABASE %s' % pub.cfg['postgresql']['database']) - cur.close() + clean_temporary_pub() @postgresql def test_sql_table_name_invalid_chars(): -- 2.17.0