test_auth_views.py 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. from flask_login import login_user
  2. from flaskbb.management import views
  3. from flaskbb.exceptions import AuthorizationRequired
  4. import pytest
  5. def test_overview_not_authorized(application, default_settings):
  6. with application.test_request_context(), pytest.raises(AuthorizationRequired) as excinfo: # noqa
  7. views.overview()
  8. assert "Authorization is required to access this area." == excinfo.value.description # noqa
  9. def test_overview_with_authorized(admin_user, application, default_settings):
  10. with application.test_request_context():
  11. login_user(admin_user)
  12. resp = views.overview()
  13. assert 'Overview' in resp
  14. def test_overview_with_supermod(super_moderator_user, application, default_settings): # noqa
  15. with application.test_request_context():
  16. login_user(super_moderator_user)
  17. resp = views.overview()
  18. assert 'Overview' in resp
  19. def test_overview_with_mod(moderator_user, application, default_settings):
  20. with application.test_request_context():
  21. login_user(moderator_user)
  22. resp = views.overview()
  23. assert 'Overview' in resp