|
| 1 | +#!/usr/bin/env python3 |
| 2 | +"""Test script to verify the footer implementation.""" |
| 3 | + |
| 4 | +import sys |
| 5 | +from pathlib import Path |
| 6 | + |
| 7 | + |
| 8 | +def test_footer_files_exist(): |
| 9 | + """Test that all required footer files exist.""" |
| 10 | + required_files = ["docs/_footer.md", "docs/css/navigation_cards.css", "mkdocs.yml"] |
| 11 | + |
| 12 | + for file_path in required_files: |
| 13 | + if not Path(file_path).exists(): |
| 14 | + print(f"❌ Missing required file: {file_path}") |
| 15 | + return False |
| 16 | + else: |
| 17 | + print(f"✅ Found required file: {file_path}") |
| 18 | + |
| 19 | + return True |
| 20 | + |
| 21 | + |
| 22 | +def test_mkdocs_config(): |
| 23 | + """Test that mkdocs.yml contains the required configuration.""" |
| 24 | + with open("mkdocs.yml") as f: |
| 25 | + content = f.read() |
| 26 | + |
| 27 | + required_items = [ |
| 28 | + "https://fonts.googleapis.com/icon?family=Material+Icons", |
| 29 | + "css/navigation_cards.css", |
| 30 | + "include-markdown", |
| 31 | + ] |
| 32 | + |
| 33 | + for item in required_items: |
| 34 | + if item in content: |
| 35 | + print(f"✅ Found in mkdocs.yml: {item}") |
| 36 | + else: |
| 37 | + print(f"❌ Missing in mkdocs.yml: {item}") |
| 38 | + return False |
| 39 | + |
| 40 | + return True |
| 41 | + |
| 42 | + |
| 43 | +def test_footer_content(): |
| 44 | + """Test that footer contains expected content.""" |
| 45 | + with open("docs/_footer.md") as f: |
| 46 | + content = f.read() |
| 47 | + |
| 48 | + expected_elements = ["nav-card", "material-icons", "bug_report", "help", "GitHub", "Slack"] |
| 49 | + |
| 50 | + for element in expected_elements: |
| 51 | + if element in content: |
| 52 | + print(f"✅ Found in footer: {element}") |
| 53 | + else: |
| 54 | + print(f"❌ Missing in footer: {element}") |
| 55 | + return False |
| 56 | + |
| 57 | + return True |
| 58 | + |
| 59 | + |
| 60 | +def test_pages_include_footer(): |
| 61 | + """Test that main pages include the footer.""" |
| 62 | + pages_to_check = ["docs/index.md", "docs/usage.md", "docs/installation.md"] |
| 63 | + |
| 64 | + for page in pages_to_check: |
| 65 | + if Path(page).exists(): |
| 66 | + with open(page) as f: |
| 67 | + content = f.read() |
| 68 | + |
| 69 | + if '{% include-markdown "_footer.md" %}' in content: |
| 70 | + print(f"✅ Footer included in: {page}") |
| 71 | + else: |
| 72 | + print(f"❌ Footer missing in: {page}") |
| 73 | + return False |
| 74 | + else: |
| 75 | + print(f"⚠️ Page not found: {page}") |
| 76 | + |
| 77 | + return True |
| 78 | + |
| 79 | + |
| 80 | +def main(): |
| 81 | + """Run all tests.""" |
| 82 | + print("🧪 Testing footer implementation...") |
| 83 | + print("=" * 50) |
| 84 | + |
| 85 | + tests = [test_footer_files_exist, test_mkdocs_config, test_footer_content, test_pages_include_footer] |
| 86 | + |
| 87 | + all_passed = True |
| 88 | + for test in tests: |
| 89 | + print(f"\n📋 Running {test.__name__}...") |
| 90 | + if not test(): |
| 91 | + all_passed = False |
| 92 | + |
| 93 | + print("\n" + "=" * 50) |
| 94 | + if all_passed: |
| 95 | + print("🎉 All tests passed! Footer implementation looks good.") |
| 96 | + return 0 |
| 97 | + else: |
| 98 | + print("❌ Some tests failed. Please check the output above.") |
| 99 | + return 1 |
| 100 | + |
| 101 | + |
| 102 | +if __name__ == "__main__": |
| 103 | + sys.exit(main()) |
0 commit comments