""" Tests for template rendering and structure Tests cover: - Template inheritance - Microformats2 markup - HTML structure and validity - Template variables and context - Flash message rendering - Error templates """ import pytest from starpunk import create_app from starpunk.notes import create_note @pytest.fixture def app(tmp_path): """Create test application""" test_data_dir = tmp_path / "data" test_data_dir.mkdir(parents=True, exist_ok=True) test_config = { "TESTING": True, "DATABASE_PATH": test_data_dir / "starpunk.db", "DATA_PATH": test_data_dir, "NOTES_PATH": test_data_dir / "notes", "SESSION_SECRET": "test-secret", "SITE_URL": "http://localhost:5000", "ADMIN_ME": "https://test.example.com", "DEV_MODE": False, "SITE_NAME": "Test StarPunk", "VERSION": "0.5.0", } app = create_app(config=test_config) yield app @pytest.fixture def client(app): """Test client""" return app.test_client() class TestBaseTemplate: """Test base.html template""" def test_base_has_doctype(self, client): """Test base template has HTML5 doctype""" response = client.get("/") assert response.status_code == 200 assert response.data.startswith(b"") def test_base_has_charset(self, client): """Test base template has charset meta tag""" response = client.get("/") assert response.status_code == 200 assert b'charset="UTF-8"' in response.data or b"charset=UTF-8" in response.data def test_base_has_viewport(self, client): """Test base template has viewport meta tag""" response = client.get("/") assert response.status_code == 200 assert b"viewport" in response.data assert b"width=device-width" in response.data def test_base_has_title(self, client): """Test base template has title""" response = client.get("/") assert response.status_code == 200 assert b"