def test_redirect(browser, logged_in_staff, mocker, settings):
"""Test the redirect behavior. If the dashboard API returns a 401 it should handle it properly."""
# Set ROOT_URLCONF to this modules path. This will cause the app to use the 'urlpatterns' value defined above
# at the module level.
settings.ROOT_URLCONF = __name__
dashboard_patch = mocker.patch('dashboard.views.UserDashboard.get', return_value=HttpResponse(
status=401,
content=json.dumps({"error": "message"}).encode()
))
browser.get("/dashboard", ignore_errors=True)
assert FAKE_RESPONSE in browser.driver.find_element_by_css_selector("body").text
assert dashboard_patch.called
评论列表
文章目录