Enable debug mode in tests.

Debug mode allows route integration tests to raise explicit exceptions on
errors, instead of returning error pages. Some portions of the test
suite need to be able to ignore exceptions (the response is not under
test) so they use a separate pytest fixture version of the app and
client that are configured with debug disabled, as it would be in
production.
This commit is contained in:
dandds
2019-08-29 13:07:24 -04:00
parent 094e44a6b0
commit 883947b75f
8 changed files with 82 additions and 32 deletions

View File

@@ -1,3 +1,5 @@
from unittest.mock import Mock
import pytest
from atst.domain.permission_sets import PermissionSets
@@ -33,16 +35,15 @@ def test_get_resources_from_context():
@pytest.fixture
def set_g(request_ctx):
def set_g(monkeypatch):
_g = Mock()
monkeypatch.setattr("atst.utils.context_processors.g", _g)
def _set_g(attr, val):
setattr(request_ctx.g, attr, val)
setattr(_g, attr, val)
yield _set_g
setattr(request_ctx.g, "application", None)
setattr(request_ctx.g, "portfolio", None)
setattr(request_ctx.g, "current_user", None)
def test_user_can_view(set_g):
owner = UserFactory.create()
@@ -77,4 +78,5 @@ def test_portfolio_no_user(set_g):
def test_portfolio_with_user(set_g):
user = UserFactory.create()
set_g("current_user", user)
set_g("portfolio", None)
assert portfolio_context() != {}