tests: always reset site-options.cfg file

This commit is contained in:
Frédéric Péters 2018-02-01 11:21:33 +01:00
parent 4b48fda3d6
commit ff1e179d45
2 changed files with 22 additions and 14 deletions

View File

@ -352,6 +352,7 @@ def test_form_access(pub):
def test_form_access_auth_context(pub):
user = create_user(pub)
pub.load_site_options()
if not pub.site_options.has_section('options'):
pub.site_options.add_section('options')
pub.site_options.set('options', 'auth-contexts', 'fedict')

View File

@ -84,18 +84,12 @@ def create_temporary_pub(sql_mode=False):
if os.path.exists(os.path.join(pub.app_dir, 'scripts')):
shutil.rmtree(os.path.join(pub.app_dir, 'scripts'))
if os.path.exists(pub.app_dir):
pub.cfg = {}
if sql_mode:
pub.cfg['postgresql'] = {'database': known_elements.sql_db_name, 'user': os.environ['USER']}
pub.cfg['misc'] = {'charset': 'utf-8'}
pub.cfg['language'] = {'language': 'en'}
pub.write_cfg()
return pub
created = False
if not os.path.exists(pub.app_dir):
os.mkdir(pub.app_dir)
created = True
os.mkdir(pub.app_dir)
os.symlink(os.path.join(os.path.dirname(__file__), 'templates'),
os.path.join(pub.app_dir, 'templates'))
# always reset site-options.cfg
fd = file(os.path.join(pub.app_dir, 'site-options.cfg'), 'w')
fd.write('[wscall-secrets]\n')
fd.write('idp.example.net = BAR\n')
@ -106,6 +100,22 @@ def create_temporary_pub(sql_mode=False):
fd.write('workflow-resubmit-action = true\n')
if sql_mode:
fd.write('postgresql = true\n')
# make sure site options are not cached
pub.site_options = None
if not created:
pub.cfg = {}
if sql_mode:
pub.cfg['postgresql'] = {'database': known_elements.sql_db_name, 'user': os.environ['USER']}
pub.cfg['misc'] = {'charset': 'utf-8'}
pub.cfg['language'] = {'language': 'en'}
pub.write_cfg()
return pub
os.symlink(os.path.join(os.path.dirname(__file__), 'templates'),
os.path.join(pub.app_dir, 'templates'))
if sql_mode:
conn = psycopg2.connect(user=os.environ['USER'])
conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
cur = conn.cursor()
@ -125,9 +135,6 @@ def create_temporary_pub(sql_mode=False):
fd.close()
# make sure site options are not cached
pub.site_options = None
return pub
def clean_temporary_pub():