Skip to content

Commit

Permalink
Add test for home page template issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Iain-S committed Dec 7, 2023
1 parent c85748a commit aadf712
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test_routes/test_frontend.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import random
from pathlib import Path
from unittest.mock import AsyncMock
from uuid import UUID

import jwt
import pytest
from databases import Database
from fastapi import HTTPException
from fastapi.templating import Jinja2Templates
from jinja2 import StrictUndefined
from pytest_mock import MockerFixture

import rctab
from rctab.crud.accounting_models import subscription, subscription_details
from rctab.crud.schema import RoleAssignment, SubscriptionState, UserRBAC
from rctab.routers.frontend import home
Expand Down Expand Up @@ -97,6 +101,16 @@ async def test_no_username_no_subscriptions(
async def test_render_home_page(mocker: MockerFixture, test_db: Database) -> None:
"""Check that we can pick up on undefined variable template issues."""

# Use StrictUndefined while testing
mocker.patch(
"rctab.routers.frontend.templates",
Jinja2Templates(
(
Path(rctab.routers.frontend.__file__).parent.parent / "templates"
).absolute(),
undefined=StrictUndefined,
),
)
subscription_id = UUID(int=random.randint(0, (2**32) - 1))

await test_db.execute(
Expand Down

0 comments on commit aadf712

Please sign in to comment.