Skip to content

Commit e04add8

Browse files
authored
Merge pull request #378 from ma10/add-missing-files-20250807
Add modifications that were supposed to be a part of PR #377
2 parents b1d9212 + c61aa16 commit e04add8

File tree

3 files changed

+58
-41
lines changed

3 files changed

+58
-41
lines changed

tools/lib/freee_a11y_gl/.flake8

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[flake8]
2+
max-line-length = 88
3+
extend-ignore = E203,W503,E501
4+
exclude =
5+
build/,
6+
dist/,
7+
*.egg-info/,
8+
__pycache__/,
9+
.git/,
10+
.tox/,
11+
.venv/,
12+
venv/
13+
per-file-ignores =
14+
# Allow unused imports in __init__.py files
15+
__init__.py:F401
16+
# Allow longer lines in test files for readability
17+
tests/*:E501

tools/lib/freee_a11y_gl/conftest.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ def clear_instances():
2828
for model_class in [Faq, FaqTag, Guideline, Category, Check, CheckTool, InfoRef, WcagSc]:
2929
if hasattr(model_class, '_instances'):
3030
model_class._instances.clear()
31-
31+
3232
# Clear RelationshipManager singleton
3333
RelationshipManager._instance = None
34-
34+
3535
yield
36-
36+
3737
# Clear again after test
3838
for model_class in [Faq, FaqTag, Guideline, Category, Check, CheckTool, InfoRef, WcagSc]:
3939
if hasattr(model_class, '_instances'):
4040
model_class._instances.clear()
41-
41+
4242
# Clear RelationshipManager singleton
4343
RelationshipManager._instance = None
4444

@@ -54,12 +54,12 @@ def setup_categories():
5454
("dynamic_content", {"ja": "動的コンテンツ", "en": "Dynamic Content"}),
5555
("text", {"ja": "テキスト", "en": "Text"})
5656
]
57-
57+
5858
categories = []
5959
for category_id, names in categories_data:
6060
category = Category(category_id, names)
6161
categories.append(category)
62-
62+
6363
return categories
6464

6565

@@ -71,12 +71,12 @@ def setup_faq_tags():
7171
("keyboard-operation", {"ja": "キーボード操作", "en": "Keyboard Operation"}),
7272
("screen-reader", {"ja": "スクリーンリーダー", "en": "Screen Reader"})
7373
]
74-
74+
7575
tags = []
7676
for tag_id, names in tags_data:
7777
tag = FaqTag(tag_id, names)
7878
tags.append(tag)
79-
79+
8080
return tags
8181

8282

@@ -113,12 +113,12 @@ def setup_wcag_sc():
113113
}
114114
})
115115
]
116-
116+
117117
wcag_scs = []
118118
for sc_id, data in wcag_data:
119119
wcag_sc = WcagSc(sc_id, data)
120120
wcag_scs.append(wcag_sc)
121-
121+
122122
return wcag_scs
123123

124124

@@ -147,38 +147,38 @@ def all_check_data():
147147
"conditions": []
148148
}
149149
]
150-
150+
151151
# Mock Config to avoid dependency issues
152152
with patch('freee_a11y_gl.models.check.Config') as mock_config:
153153
mock_config.get_severity_tag.side_effect = lambda severity, lang: {
154154
('normal', 'ja'): '[NORMAL]',
155155
('high', 'ja'): '[HIGH]'
156156
}.get((severity, lang), f'[{severity.upper()}]')
157-
157+
158158
mock_config.get_check_target_name.side_effect = lambda target, lang: {
159159
('code', 'ja'): 'コード',
160160
('design', 'ja'): 'デザイン'
161161
}.get((target, lang), target)
162-
162+
163163
mock_config.get_platform_name.side_effect = lambda platform, lang: {
164164
('web', 'ja'): 'Web',
165165
('mobile', 'ja'): 'モバイル'
166166
}.get((platform, lang), platform)
167-
167+
168168
mock_config.get_list_separator.return_value = '、'
169-
169+
170170
# Mock RelationshipManager
171171
with patch('freee_a11y_gl.models.base.BaseModel._get_relationship_manager') as mock_get_rel:
172172
mock_rel = MagicMock()
173173
mock_get_rel.return_value = mock_rel
174174
mock_rel.get_related_objects.return_value = []
175175
mock_rel.get_sorted_related_objects.return_value = []
176-
176+
177177
checks = []
178178
for data in checks_data:
179179
check = Check(data)
180180
checks.append(check)
181-
181+
182182
return checks
183183

184184

@@ -277,13 +277,13 @@ def all_guideline_data(setup_categories):
277277
"category": "dynamic_content"
278278
}
279279
]
280-
280+
281281
# Don't mock RelationshipManager for guidelines to allow real relationships
282282
guidelines = []
283283
for data in guidelines_data:
284284
guideline = Guideline(data)
285285
guidelines.append(guideline)
286-
286+
287287
return guidelines
288288

289289

@@ -344,13 +344,13 @@ def _create_faq(faq_id):
344344
"guidelines": []
345345
}
346346
}
347-
347+
348348
if faq_id not in faq_data:
349349
raise ValueError(f"Unknown FAQ ID: {faq_id}")
350-
350+
351351
# Don't mock RelationshipManager for FAQ creation to allow real relationships
352352
return Faq(faq_data[faq_id])
353-
353+
354354
return _create_faq
355355

356356

@@ -409,20 +409,20 @@ def _create_guideline(guideline_id):
409409
"platform": ["web"]
410410
}
411411
}
412-
412+
413413
if guideline_id not in guidelines_data:
414414
raise ValueError(f"Unknown Guideline ID: {guideline_id}")
415-
415+
416416
# Mock RelationshipManager for guideline creation
417417
with patch('freee_a11y_gl.models.content.RelationshipManager') as mock_rel_manager:
418418
mock_rel = MagicMock()
419419
mock_rel_manager.return_value = mock_rel
420-
420+
421421
# Create mock category based on guideline data
422422
mock_category = MagicMock()
423423
guideline_data = guidelines_data[guideline_id]
424424
category_id = guideline_data["category"]
425-
425+
426426
if category_id == "markup":
427427
mock_category.names = {"ja": "マークアップと実装", "en": "Markup and Implementation"}
428428
mock_category.id = "markup"
@@ -435,15 +435,15 @@ def _create_guideline(guideline_id):
435435
mock_category.names = {"ja": "テキスト", "en": "Text"}
436436
mock_category.id = "text"
437437
mock_category.get_name.side_effect = lambda lang: {"ja": "テキスト", "en": "Text"}[lang]
438-
438+
439439
def mock_get_related_objects(obj, relation_type):
440440
if relation_type == "category":
441441
return [mock_category]
442442
return []
443-
443+
444444
mock_rel.get_related_objects.side_effect = mock_get_related_objects
445445
mock_rel.get_sorted_related_objects.return_value = []
446-
446+
447447
return Guideline(guidelines_data[guideline_id])
448-
448+
449449
return _create_guideline

tools/lib/freee_a11y_gl/run_tests.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
def run_tests():
99
"""Run all tests and provide a summary."""
10-
10+
1111
test_suites = [
1212
("Core Config Tests", "tests/core/test_config.py"),
1313
("Core Utils Tests", "tests/core/test_utils.py"),
@@ -21,53 +21,53 @@ def run_tests():
2121
("YAML Processor Tests", "tests/yaml_processor/test_process_yaml.py"),
2222
("RST Processor Tests", "tests/yaml_processor/test_rst_processor.py"),
2323
]
24-
24+
2525
results = []
26-
26+
2727
for name, test_path in test_suites:
2828
print(f"\n{'='*60}")
2929
print(f"Running {name}")
3030
print('='*60)
31-
31+
3232
try:
3333
result = subprocess.run(
3434
[sys.executable, "-m", "pytest", test_path, "-v"],
3535
capture_output=True,
3636
text=True,
3737
cwd="/home/max/work/a11y-guidelines/tools/lib/freee_a11y_gl"
3838
)
39-
39+
4040
if result.returncode == 0:
4141
print(f"✅ {name}: PASSED")
4242
results.append((name, "PASSED", ""))
4343
else:
4444
print(f"❌ {name}: FAILED")
4545
results.append((name, "FAILED", result.stdout + result.stderr))
46-
46+
4747
except Exception as e:
4848
print(f"💥 {name}: ERROR - {e}")
4949
results.append((name, "ERROR", str(e)))
50-
50+
5151
# Summary
5252
print(f"\n{'='*60}")
5353
print("TEST SUMMARY")
5454
print('='*60)
55-
55+
5656
passed = sum(1 for _, status, _ in results if status == "PASSED")
5757
failed = sum(1 for _, status, _ in results if status == "FAILED")
5858
errors = sum(1 for _, status, _ in results if status == "ERROR")
59-
59+
6060
for name, status, output in results:
6161
icon = "✅" if status == "PASSED" else "❌" if status == "FAILED" else "💥"
6262
print(f"{icon} {name}: {status}")
6363
if status != "PASSED" and output:
6464
print(f" {output[:200]}...")
65-
65+
6666
print(f"\nTotal: {len(results)} test suites")
6767
print(f"Passed: {passed}")
6868
print(f"Failed: {failed}")
6969
print(f"Errors: {errors}")
70-
70+
7171
return failed + errors == 0
7272

7373

0 commit comments

Comments
 (0)