from flask import url_for from core_notifications import views class TestViews: def test_health(self, app): url = url_for("core.health") with app.test_client() as client: resp = client.get(url) assert resp.status_code == 200 assert resp.json == {"status": "ok"} def test_home_anonymous(self, app, mocker): mocker.spy(views, "render_template") url = url_for("core.home") with app.test_client() as client: resp = client.get(url) assert resp.status_code == 200 assert views.render_template.call_args_list == [ mocker.call("home.html") ] def test_home_authenticated(self, app, mocker, authorized_admin): url = url_for("core.home") with app.test_client() as client: resp = client.get(url) assert resp.status_code == 302 assert resp.location == url_for("templating.list_templates") def test_admin(self, app, mocker): url = url_for("core.admin") with app.test_client() as client: resp = client.get(url) assert resp.status_code == 302 assert resp.location == url_for("templating.list_templates")