From 017a88013cd630c7765f9b91a2fc4f42f776c8d1 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Sep 20 2019 06:25:22 +0000 Subject: frontend: FTBFS rawhide Fix the test_fork_copr_projects_with_more_builds test by creating new app context. For F32+ (something changed), per test case failure: > raise RuntimeError(_app_ctx_err_msg) E RuntimeError: Working outside of application context. E E This typically means that you attempted to use functionality that needed E to interface with the current application object in some way. To solve E this, set up an application context with app.app_context(). See the E documentation for more information. To allow wrapping already wrapped method, I needed to fix the decorator to bypass **kwargs as well. --- diff --git a/frontend/coprs_frontend/tests/coprs_test_case.py b/frontend/coprs_frontend/tests/coprs_test_case.py index 9c10214..289e657 100644 --- a/frontend/coprs_frontend/tests/coprs_test_case.py +++ b/frontend/coprs_frontend/tests/coprs_test_case.py @@ -621,8 +621,8 @@ def new_app_context(fn): https://stackoverflow.com/questions/19395697/sqlalchemy-session-not-getting-removed-properly-in-flask-testing """ @wraps(fn) - def wrapper(fn, fn_self, *args): + def wrapper(fn, fn_self, *args, **kwargs): with coprs.app.app_context(): - return fn(fn_self, *args) + return fn(fn_self, *args, **kwargs) return decorator.decorator(wrapper, fn) diff --git a/frontend/coprs_frontend/tests/test_logic/test_complex_logic.py b/frontend/coprs_frontend/tests/test_logic/test_complex_logic.py index e5f0a7b..b71b53e 100644 --- a/frontend/coprs_frontend/tests/test_logic/test_complex_logic.py +++ b/frontend/coprs_frontend/tests/test_logic/test_complex_logic.py @@ -6,7 +6,7 @@ from coprs import models, helpers, app from copr_common.enums import ActionTypeEnum from coprs.logic.actions_logic import ActionsLogic from coprs.logic.complex_logic import ComplexLogic, ProjectForking -from tests.coprs_test_case import CoprsTestCase +from tests.coprs_test_case import CoprsTestCase, new_app_context class TestComplexLogic(CoprsTestCase): @@ -25,6 +25,7 @@ class TestComplexLogic(CoprsTestCase): assert data["copr"] == "dstname" assert data["builds_map"] == {'srpm-builds': {'bar': '00000005'},'fedora-18-x86_64': {'bar': '00000005-hello-world'}} + @new_app_context @mock.patch("flask.g") def test_fork_copr_projects_with_more_builds(self, mc_flask_g, f_users, f_fork_prepare, f_db): mc_flask_g.user.name = self.u2.name