Testing & Project Checks

1. lila.testing

tests/test_app.py
import unittest
from lila.testing import TestClient, login, csrf_headers, temp_database, override_env
from app.models.product import Product

class ProductTests(unittest.IsolatedAsyncioTestCase):
    async def test_crud(self):
        async with temp_database(Product):               # throwaway SQLite, tables created
            await Product.insert_async(name="Coffee", price=5)
            page = await Product.paginate_async(price__gte=1)
            self.assertEqual(page["total"], 1)

class ApiTests(unittest.TestCase):
    def setUp(self):
        self.client = TestClient()                       # imports main:app

    def test_requires_login(self):
        self.assertEqual(self.client.get("/api/me").status_code, 401)
        login(self.client, {"id": 1, "email": "a@b.c", "role": "admin"})
        self.assertEqual(self.client.get("/api/me").status_code, 200)

    def test_csrf(self):
        res = self.client.post("/api/items", json={"name": "x"}, headers=csrf_headers(self.client))
        self.assertEqual(res.status_code, 200)

    def test_settings(self):
        with override_env(DEBUG="False", CACHE_DRIVER="memory"):
            ...

2. lila doctor

Checks Python, .env, SECRET_KEY, database, templates, .env values, translations and whether the compiled Tailwind CSS exists for production.

3. .env validation

Invalid values are reported on startup and by lila doctor instead of silently becoming defaults:

Output
[Lila config] ❌ PORT="abc" must be a whole number.
[Lila config] ❌ CACHE_DRIVER="mem" must be one of: memory, redis, file.
[Lila config] ❌ APP_URL="example.com" must start with http:// or https://.
⚠️ .env: DEBUG=True with APP_ENV=production: tracebacks and /debug would be exposed.

From code: from lila.core.config import validate_settings; errors, warnings = validate_settings().

4. Translations: lila i18n check

Terminal
lila i18n check            # keys used in templates/app/*.py missing per language
lila i18n check --strict   # exit code 1 (CI)

Keys are collected from translate['key'], t('key') and Translate.t(key='key'); a key is available when it exists in Lila's built-in locales or app/locales/<lang>.json. Keys present in one of your locale files but missing in another are listed too.