diff --git a/pagure/__init__.py b/pagure/__init__.py index 6c07a5e..6c00461 100644 --- a/pagure/__init__.py +++ b/pagure/__init__.py @@ -200,7 +200,7 @@ if APP.config.get('PAGURE_CI_SERVICES'): pagure.lib.set_pagure_ci(APP.config['PAGURE_CI_SERVICES']) -if not APP.debug: +if not APP.debug and not APP.config.get('DEBUG', False): APP.logger.addHandler(pagure.mail_logging.get_mail_handler( smtp_server=APP.config.get('SMTP_SERVER', '127.0.0.1'), mail_admin=APP.config.get('MAIL_ADMIN', APP.config['EMAIL_ERROR']), diff --git a/pagure/lib/notify.py b/pagure/lib/notify.py index c14bd67..3ff5018 100644 --- a/pagure/lib/notify.py +++ b/pagure/lib/notify.py @@ -22,7 +22,6 @@ import urlparse import re import smtplib import time -import warnings import flask import pagure @@ -50,7 +49,7 @@ def fedmsg_publish(*args, **kwargs): # pragma: no cover try: import fedmsg fedmsg.publish(*args, **kwargs) - except Exception as err: + except Exception: _log.exception('Error sending fedmsg') diff --git a/tests/__init__.py b/tests/__init__.py index 9c962ed..9142cd5 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -25,14 +25,15 @@ logging.basicConfig(stream=sys.stderr) # Always enable performance counting for tests os.environ['PAGURE_PERFREPO'] = 'true' +from contextlib import contextmanager from datetime import date from datetime import datetime from datetime import timedelta from functools import wraps +import mock import pygit2 -from contextlib import contextmanager from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from sqlalchemy.orm import scoped_session @@ -67,6 +68,7 @@ REMOTE_GIT_FOLDER = '%(path)s/remotes' ATTACHMENTS_FOLDER = '%(path)s/attachments' DB_URL = '%(dburl)s' ALLOW_PROJECT_DOWAIT = True +DEBUG = True """ @@ -145,6 +147,7 @@ class SimplePagureTest(unittest.TestCase): Simple Test class that does not set a broker/worker """ + @mock.patch('pagure.lib.notify.fedmsg_publish', mock.MagicMock()) def __init__(self, method_name='runTest'): """ Constructor. """ unittest.TestCase.__init__(self, method_name) diff --git a/tests/test_config b/tests/test_config index 04970a4..a810db7 100644 --- a/tests/test_config +++ b/tests/test_config @@ -1,2 +1,3 @@ PAGURE_CI_SERVICES = ['jenkins'] ALLOW_PROJECT_DOWAIT = True +DEBUG=True diff --git a/tests/test_pagure_flask_ui_app_give_project.py b/tests/test_pagure_flask_ui_app_give_project.py index 1b07529..2335694 100644 --- a/tests/test_pagure_flask_ui_app_give_project.py +++ b/tests/test_pagure_flask_ui_app_give_project.py @@ -196,6 +196,7 @@ class PagureFlaskGiveRepotests(tests.SimplePagureTest): self._check_user() @patch.dict('pagure.APP.config', {'PAGURE_ADMIN_USERS': 'foo'}) + @patch('pagure.lib.git.generate_gitolite_acls', MagicMock()) def test_give_project_not_owner_but_admin(self): """ Test the give_project endpoint. @@ -229,6 +230,7 @@ class PagureFlaskGiveRepotests(tests.SimplePagureTest): self._check_user('foo') @patch.dict('pagure.APP.config', {'PAGURE_ADMIN_USERS': 'foo'}) + @patch('pagure.lib.git.generate_gitolite_acls', MagicMock()) def test_give_project(self): """ Test the give_project endpoint. """ @@ -261,6 +263,7 @@ class PagureFlaskGiveRepotests(tests.SimplePagureTest): self.assertEqual(project.users[0].user, 'pingou') @patch.dict('pagure.APP.config', {'PAGURE_ADMIN_USERS': 'foo'}) + @patch('pagure.lib.git.generate_gitolite_acls', MagicMock()) def test_give_project_already_user(self): """ Test the give_project endpoint when the new main_admin is already a committer on the project. """ diff --git a/tests/test_pagure_flask_ui_fork.py b/tests/test_pagure_flask_ui_fork.py index ffd9cf4..f13a3b8 100644 --- a/tests/test_pagure_flask_ui_fork.py +++ b/tests/test_pagure_flask_ui_fork.py @@ -2207,6 +2207,7 @@ index 0000000..2a552bb # UI test for deleted main output = self.app.get('/fork/foo/test') self.assertEqual(output.status_code, 200) + print output.data self.assertIn('Fork from a deleted repository\n', output.data) # Testing commit endpoint diff --git a/tests/test_pagure_flask_ui_no_master_branch.py b/tests/test_pagure_flask_ui_no_master_branch.py index a410eb8..9a899e6 100644 --- a/tests/test_pagure_flask_ui_no_master_branch.py +++ b/tests/test_pagure_flask_ui_no_master_branch.py @@ -128,8 +128,9 @@ class PagureFlaskNoMasterBranchtests(tests.SimplePagureTest): # With git repo output = self.app.get('/test') self.assertEqual(output.status_code, 200) + self.assertIn('
', output.data) self.assertIn( - '
\n