Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ incfiles.mk
__pycache__/
*:Zone.Identifier
*.egg-info/
.coverage
14 changes: 14 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Testing
pytest==8.0.0
pytest-cov==4.1.0

# Type checking
mypy==1.9.0
types-PyYAML==6.0.12.12

# Code formatting
black==24.2.0
isort==5.13.2

# YAML parsing (needed for tests)
PyYAML==6.0.1
449 changes: 449 additions & 0 deletions tools/lib/freee_a11y_gl/conftest.py

Large diffs are not rendered by default.

23 changes: 19 additions & 4 deletions tools/lib/freee_a11y_gl/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ build-backend = "setuptools.build_meta"

[project]
name = "freee_a11y_gl"
version = "0.2.0"
version = "0.2.2"
description = "A module to process a11y guidelines data"
authors = [
{name = "Masafumi NAKANE", email = "[email protected]"}
]
requires-python = ">=3.8"
requires-python = ">=3.9"
dependencies = [
"pyyaml>=6.0",
"gitpython>=3.1.43",
"pydantic>=2.7.0",
"importlib_resources>=1.3.0; python_version<'3.9'"
"pydantic>=2.7.0"
]

[tool.setuptools]
Expand All @@ -23,3 +22,19 @@ include-package-data = true

[tool.setuptools.package-data]
freee_a11y_gl = ["data/*.yaml"]

[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = ["test_*.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
addopts = [
"-v",
"--tb=short",
"--strict-markers",
"--disable-warnings",
]
markers = [
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
"integration: marks tests as integration tests",
]
76 changes: 76 additions & 0 deletions tools/lib/freee_a11y_gl/run_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env python3
"""Test runner script for freee_a11y_gl tests."""

import subprocess
import sys


def run_tests():
"""Run all tests and provide a summary."""

test_suites = [
("Core Config Tests", "tests/core/test_config.py"),
("Core Utils Tests", "tests/core/test_utils.py"),
("Base Model Tests", "tests/models/test_base.py"),
("Check Model Tests", "tests/models/test_check.py"),
("FAQ Article Tests", "tests/models/test_faq_article.py"),
("Guideline Tests", "tests/models/test_guideline.py"),
("Info Reference Tests", "tests/models/test_info_ref.py"),
("FAQ Tag Tests", "tests/models/faq/test_tag.py"),
("RelationshipManager Tests", "tests/managers/test_relationship_manager.py"),
("YAML Processor Tests", "tests/yaml_processor/test_process_yaml.py"),
("RST Processor Tests", "tests/yaml_processor/test_rst_processor.py"),
]

results = []

for name, test_path in test_suites:
print(f"\n{'='*60}")
print(f"Running {name}")
print('='*60)

try:
result = subprocess.run(
[sys.executable, "-m", "pytest", test_path, "-v"],
capture_output=True,
text=True,
cwd="/home/max/work/a11y-guidelines/tools/lib/freee_a11y_gl"
)

if result.returncode == 0:
print(f"✅ {name}: PASSED")
results.append((name, "PASSED", ""))
else:
print(f"❌ {name}: FAILED")
results.append((name, "FAILED", result.stdout + result.stderr))

except Exception as e:
print(f"💥 {name}: ERROR - {e}")
results.append((name, "ERROR", str(e)))

# Summary
print(f"\n{'='*60}")
print("TEST SUMMARY")
print('='*60)

passed = sum(1 for _, status, _ in results if status == "PASSED")
failed = sum(1 for _, status, _ in results if status == "FAILED")
errors = sum(1 for _, status, _ in results if status == "ERROR")

for name, status, output in results:
icon = "✅" if status == "PASSED" else "❌" if status == "FAILED" else "💥"
print(f"{icon} {name}: {status}")
if status != "PASSED" and output:
print(f" {output[:200]}...")

print(f"\nTotal: {len(results)} test suites")
print(f"Passed: {passed}")
print(f"Failed: {failed}")
print(f"Errors: {errors}")

return failed + errors == 0


if __name__ == "__main__":
success = run_tests()
sys.exit(0 if success else 1)
4 changes: 0 additions & 4 deletions tools/lib/freee_a11y_gl/src/freee_a11y_gl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from .relationship_manager import RelationshipManager

# Constants and utilities
from .constants import *
from .source import get_src_path
from .initializer import setup_instances
from .info_utils import get_info_links
Expand All @@ -24,9 +23,6 @@
'WcagSc', 'InfoRef', 'AxeRule', 'CheckTool',
# Managers
'RelationshipManager',
# Constants
'PLATFORM_NAMES', 'SEVERITY_TAGS', 'CHECK_TARGETS',
'IMPLEMENTATION_TARGETS',
# Utils
'get_src_path', 'setup_instances', 'get_info_links',
'get_version_info',
Expand Down
40 changes: 40 additions & 0 deletions tools/lib/freee_a11y_gl/src/freee_a11y_gl/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ def get_platform_name(cls, platform: str, lang: Optional[LanguageCode] = None) -
effective_lang = lang if lang is not None else settings.get("languages.default", "ja")
return settings.message_catalog.get_platform_name(platform, effective_lang)

@classmethod
def get_implementation_target_name(cls, target: str, lang: Optional[LanguageCode] = None) -> str:
"""Get localized implementation target name."""
effective_lang = lang if lang is not None else settings.get("languages.default", "ja")
return settings.message_catalog.get_implementation_target(target, effective_lang)

@classmethod
def get_faq_path(cls) -> str:
"""Get FAQ path
Expand Down Expand Up @@ -262,3 +268,37 @@ def get_default_language(cls) -> str:
Default language code
"""
return settings.get("languages.default", "ja")

@classmethod
def get_yaml_validation_mode(cls) -> str:
"""Get YAML validation mode.

Returns:
YAML validation mode ("strict", "warning", or "disabled")
"""
return settings.get("validation.yaml_validation", "strict")

@classmethod
def set_yaml_validation_mode(cls, mode: str) -> None:
"""Set YAML validation mode.

Args:
mode: Validation mode ("strict", "warning", or "disabled")

Raises:
ValueError: If mode is not valid
"""
valid_modes = ["strict", "warning", "disabled"]
if mode not in valid_modes:
raise ValueError(f"Invalid validation mode: {mode}. Must be one of {valid_modes}")

settings.set("validation.yaml_validation", mode)

@classmethod
def get_axe_core_config(cls) -> Dict[str, str]:
"""Get axe-core configuration.

Returns:
Dictionary containing axe-core configuration settings
"""
return settings.get("axe_core", {})
121 changes: 2 additions & 119 deletions tools/lib/freee_a11y_gl/src/freee_a11y_gl/constants.py
Original file line number Diff line number Diff line change
@@ -1,119 +1,2 @@
# List of check tools and their names
CHECK_TOOLS = {
'nvda': {
'ja': 'NVDA',
'en': 'NVDA'
},
'macos-vo': {
'ja': 'macOS VoiceOver',
'en': 'macOS VoiceOver'
},
'axe': {
'ja': 'axe DevTools',
'en': 'axe DevTools'
},
'ios-vo': {
'ja': 'iOS VoiceOver',
'en': 'iOS VoiceOver'
},
'android-tb': {
'ja': 'Android TalkBack',
'en': 'Android TalkBack'
},
'keyboard': {
'ja': 'キーボード操作',
'en': 'Keyboard'
},
'misc': {
'ja': 'その他の手段',
'en': 'Miscellaneous Methods'
}
}

# Check targets
CHECK_TARGETS = {
'design': {
'ja': 'デザイン',
'en': 'Design'
},
'code': {
'ja': 'コード',
'en': 'Code'
},
'product': {
'ja': 'プロダクト',
'en': 'Product'
}
}

# Names for checks/guidelines/procedures target platforms
PLATFORM_NAMES = {
'web': {
'ja': 'Web',
'en': 'Web'
},
'mobile': {
'ja': 'モバイル',
'en': 'Mobile'
},
'general': {
'ja': 'Web、モバイル',
'en': 'Web, Mobile'
},
'ios': {
'ja': 'iOS',
'en': 'iOS'
},
'android': {
'ja': 'Android',
'en': 'Android'
}
}

# Severity tags and its display names
SEVERITY_TAGS = {
'critical': {
'ja': '[CRITICAL]',
'en': '[CRITICAL]'
},
'major': {
'ja': '[MAJOR]',
'en': '[MAJOR]'
},
'normal': {
'ja': '[NORMAL]',
'en': '[NORMAL]'
},
'minor': {
'ja': '[MINOR]',
'en': '[MINOR]'
}
}

# Possible targets for implementation examples
IMPLEMENTATION_TARGETS = {
'web': {
'ja': 'Web',
'en': 'Web'
},
'android': {
'ja': 'Android',
'en': 'Android'
},
'ios': {
'ja': 'iOS',
'en': 'iOS'
}
}

# for axe rules
AXE_CORE = {
'submodule_name': 'vendor/axe-core',
'base_dir': 'vendor/axe-core', # 追加: yaml2rstでも使用
'deque_url': 'https://dequeuniversity.com/rules/axe/',
'msg_ja_file': 'locales/ja.json',
'pkg_file': 'package.json',
'rules_dir': 'lib/rules',
'locale_dir': 'locales', # 追加: yaml2rstでも使用
'locale_ja_file': 'ja.json' # 追加: yaml2rstでも使用
}
# This file previously contained constants that have been moved to the configuration system.
# All constants are now managed through the Config class and YAML configuration files.
13 changes: 13 additions & 0 deletions tools/lib/freee_a11y_gl/src/freee_a11y_gl/data/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ paths:
guidelines: "/categories/"
faq: "/faq/articles/"

validation:
yaml_validation: "strict" # strict | warning | disabled

# axe-core configuration
axe_core:
submodule_name: "vendor/axe-core"
base_dir: "vendor/axe-core"
deque_url: "https://dequeuniversity.com/rules/axe/"
pkg_file: "package.json"
rules_dir: "lib/rules"
locale_dir: "locales"
locale_ja_file: "ja.json"

# Profile-specific configurations
profiles:
yaml2rst:
Expand Down
Loading