From 1a0280e14a149601c20d458b3ddcd9a398fd6762 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 14 2016 10:18:25 +0000 Subject: Reload pagure before and after running the tests for the old URL scheme This is needed for the configuration file to be taken into account for the tests and ignored about afterward. --- diff --git a/tests/test_pagure_flask_ui_old_commit.py b/tests/test_pagure_flask_ui_old_commit.py index 33b7116..b2ed0f7 100644 --- a/tests/test_pagure_flask_ui_old_commit.py +++ b/tests/test_pagure_flask_ui_old_commit.py @@ -42,6 +42,22 @@ class PagureFlaskRepoOldUrltests(tests.Modeltests): """ Set up the environnment, ran before every tests. """ super(PagureFlaskRepoOldUrltests, self).setUp() + # We need to reload pagure as otherwise the configuration file will + # not be taken into account + pagure.APP.view_functions = {} + os.environ['PAGURE_CONFIG'] = CONFIG + + reload(pagure) + reload(pagure.lib) + reload(pagure.lib.model) + reload(pagure.ui.admin) + reload(pagure.ui.app) + reload(pagure.ui.groups) + reload(pagure.ui.repo) + reload(pagure.ui.filters) + reload(pagure.ui.issues) + reload(pagure.ui.fork) + pagure.APP.config['TESTING'] = True pagure.SESSION = self.session pagure.ui.SESSION = self.session @@ -50,6 +66,7 @@ class PagureFlaskRepoOldUrltests(tests.Modeltests): pagure.ui.repo.SESSION = self.session pagure.APP.config['OLD_VIEW_COMMIT_ENABLED'] = True + pagure.APP.config['EMAIL_SEND'] = False pagure.APP.config['GIT_FOLDER'] = tests.HERE pagure.APP.config['FORK_FOLDER'] = os.path.join( tests.HERE, 'forks') @@ -63,6 +80,41 @@ class PagureFlaskRepoOldUrltests(tests.Modeltests): tests.HERE, 'releases') self.app = pagure.APP.test_client() + def tearDown(self): + """ Tear down the environnment, after every tests. """ + super(PagureFlaskRepoOldUrltests, self).tearDown() + if 'PAGURE_CONFIG' in os.environ: + del os.environ['PAGURE_CONFIG'] + + # We need to reload pagure as otherwise the configuration file will + # remain set for the other tests + pagure.APP.view_functions = {} + + reload(pagure) + reload(pagure.lib) + reload(pagure.lib.model) + reload(pagure.hooks) + reload(pagure.hooks.mail) + reload(pagure.hooks.irc) + reload(pagure.hooks.fedmsg) + reload(pagure.hooks.pagure_force_commit) + reload(pagure.hooks.pagure_hook) + reload(pagure.hooks.pagure_request_hook) + reload(pagure.hooks.pagure_ticket_hook) + reload(pagure.hooks.rtd) + reload(pagure.ui.admin) + reload(pagure.ui.app) + reload(pagure.ui.groups) + reload(pagure.ui.repo) + reload(pagure.ui.filters) + reload(pagure.ui.plugins) + reload(pagure.ui.issues) + reload(pagure.ui.fork) + + pagure.APP.config['EMAIL_SEND'] = False + pagure.LOG.handlers = [] + + def test_view_commit_old(self): """ Test the view_commit_old endpoint. """