@@ -24,21 +24,21 @@ def component_manager(components_dir):
2424def pre_commit_component (component_manager ):
2525 """Get the Pre-commit component."""
2626 components = component_manager ._discover_components ()
27- return components .get (' pre_commit' )
27+ return components .get (" pre_commit" )
2828
2929
3030def test_pre_commit_component_exists (pre_commit_component ):
3131 """Test that Pre-commit component exists and has correct metadata."""
3232 assert pre_commit_component is not None
33- assert pre_commit_component .name == ' pre_commit'
34- assert pre_commit_component .display_name == ' Pre-commit Hooks'
35- assert ' Pre-commit hooks' in pre_commit_component .description
36- assert pre_commit_component .category == ' quality'
33+ assert pre_commit_component .name == " pre_commit"
34+ assert pre_commit_component .display_name == " Pre-commit Hooks"
35+ assert " Pre-commit hooks" in pre_commit_component .description
36+ assert pre_commit_component .category == " quality"
3737
3838
3939def test_pre_commit_dependencies (pre_commit_component ):
4040 """Test that Pre-commit has correct dependencies."""
41- expected_dependencies = {' task_automation' , ' github_actions' }
41+ expected_dependencies = {" task_automation" , " github_actions" }
4242 assert set (pre_commit_component .dependencies ) == expected_dependencies
4343
4444
@@ -49,9 +49,7 @@ def test_pre_commit_no_conflicts(pre_commit_component):
4949
5050def test_pre_commit_cookiecutter_vars (pre_commit_component ):
5151 """Test that Pre-commit sets correct cookiecutter variables."""
52- expected_vars = {
53- 'use_pre_commit' : True
54- }
52+ expected_vars = {"use_pre_commit" : True }
5553
5654 for key , expected_value in expected_vars .items ():
5755 assert key in pre_commit_component .cookiecutter_vars
@@ -60,11 +58,9 @@ def test_pre_commit_cookiecutter_vars(pre_commit_component):
6058
6159def test_pre_commit_files (pre_commit_component ):
6260 """Test that Pre-commit component has correct files."""
63- expected_files = {
64- '.pre-commit-config.yaml'
65- }
61+ expected_files = {".pre-commit-config.yaml" }
6662
67- actual_files = {file_config [' dest' ] for file_config in pre_commit_component .files }
63+ actual_files = {file_config [" dest" ] for file_config in pre_commit_component .files }
6864 assert actual_files == expected_files
6965
7066
@@ -73,108 +69,108 @@ def test_pre_commit_config_content(components_dir):
7369 config_path = components_dir / "pre_commit" / "files" / ".pre-commit-config.yaml.j2"
7470 assert config_path .exists ()
7571
76- content = config_path .read_text (encoding = ' utf-8' )
72+ content = config_path .read_text (encoding = " utf-8" )
7773
7874 # Check for conditional uv usage
79- assert ' use_uv' in content
80- assert ' uv-pre-commit' in content
81- assert ' uv-lock' in content
75+ assert " use_uv" in content
76+ assert " uv-pre-commit" in content
77+ assert " uv-lock" in content
8278
8379 # Check for conditional GitHub Actions integration
84- assert ' use_github_actions' in content
85- assert ' check-github-workflows' in content
86- assert ' actionlint' in content
80+ assert " use_github_actions" in content
81+ assert " check-github-workflows" in content
82+ assert " actionlint" in content
8783
8884 # Check for YAML formatting
89- assert ' yamlfmt' in content
85+ assert " yamlfmt" in content
9086
9187
9288def test_component_yaml_syntax (components_dir ):
9389 """Test that component.yaml has valid syntax."""
9490 component_yaml = components_dir / "pre_commit" / "component.yaml"
9591 assert component_yaml .exists ()
9692
97- with open (component_yaml , encoding = ' utf-8' ) as f :
93+ with open (component_yaml , encoding = " utf-8" ) as f :
9894 config = yaml .safe_load (f )
9995
10096 # Validate required fields
101- required_fields = [' name' , ' display_name' , ' description' , ' category' , ' dependencies' , ' files' ]
97+ required_fields = [" name" , " display_name" , " description" , " category" , " dependencies" , " files" ]
10298 for field in required_fields :
10399 assert field in config
104100
105101 # Validate dependencies
106- assert ' task_automation' in config [' dependencies' ]
107- assert ' github_actions' in config [' dependencies' ]
102+ assert " task_automation" in config [" dependencies" ]
103+ assert " github_actions" in config [" dependencies" ]
108104
109105 # Validate files structure
110- for file_config in config [' files' ]:
111- assert ' src' in file_config
112- assert ' dest' in file_config
106+ for file_config in config [" files" ]:
107+ assert " src" in file_config
108+ assert " dest" in file_config
113109
114110
115111def test_file_templates_exist (components_dir ):
116112 """Test that all referenced template files exist."""
117113 component_yaml = components_dir / "pre_commit" / "component.yaml"
118114
119- with open (component_yaml , encoding = ' utf-8' ) as f :
115+ with open (component_yaml , encoding = " utf-8" ) as f :
120116 config = yaml .safe_load (f )
121117
122118 files_dir = components_dir / "pre_commit" / "files"
123119
124- for file_config in config [' files' ]:
125- src_file = files_dir / file_config [' src' ]
120+ for file_config in config [" files" ]:
121+ src_file = files_dir / file_config [" src" ]
126122 assert src_file .exists (), f"Template file not found: { src_file } "
127123
128124
129125def test_uv_integration (components_dir ):
130126 """Test that pre-commit config integrates with uv."""
131127 config_path = components_dir / "pre_commit" / "files" / ".pre-commit-config.yaml.j2"
132- content = config_path .read_text (encoding = ' utf-8' )
128+ content = config_path .read_text (encoding = " utf-8" )
133129
134130 # Should include uv-specific hooks
135- assert ' uv-pre-commit' in content
136- assert ' uv-lock' in content
131+ assert " uv-pre-commit" in content
132+ assert " uv-lock" in content
137133
138134
139135def test_conditional_uv_usage (components_dir ):
140136 """Test conditional uv usage in pre-commit hooks."""
141137 config_path = components_dir / "pre_commit" / "files" / ".pre-commit-config.yaml.j2"
142- content = config_path .read_text (encoding = ' utf-8' )
138+ content = config_path .read_text (encoding = " utf-8" )
143139
144140 # Should have conditional blocks for uv
145- assert ' if cookiecutter.use_uv' in content
146- assert ' uv-lock' in content
141+ assert " if cookiecutter.use_uv" in content
142+ assert " uv-lock" in content
147143
148144 # Should have conditional ending
149- assert ' endif' in content
145+ assert " endif" in content
150146
151147
152148def test_github_actions_integration (components_dir ):
153149 """Test GitHub Actions integration in pre-commit config."""
154150 config_path = components_dir / "pre_commit" / "files" / ".pre-commit-config.yaml.j2"
155- content = config_path .read_text (encoding = ' utf-8' )
151+ content = config_path .read_text (encoding = " utf-8" )
156152
157153 # Should have conditional GitHub Actions specific hooks
158- assert ' if cookiecutter.use_github_actions' in content
159- assert ' check-github-workflows' in content
160- assert ' actionlint' in content
154+ assert " if cookiecutter.use_github_actions" in content
155+ assert " check-github-workflows" in content
156+ assert " actionlint" in content
161157
162158
163159def test_yamlfmt_integration (components_dir ):
164160 """Test YAML formatting integration."""
165161 config_path = components_dir / "pre_commit" / "files" / ".pre-commit-config.yaml.j2"
166- content = config_path .read_text (encoding = ' utf-8' )
162+ content = config_path .read_text (encoding = " utf-8" )
167163
168164 # Should include yamlfmt for YAML formatting
169- assert ' yamlfmt' in content
170- assert ' google/yamlfmt' in content
165+ assert " yamlfmt" in content
166+ assert " google/yamlfmt" in content
171167
172168
173169def test_actionlint_integration (components_dir ):
174170 """Test GitHub Actions linting integration."""
175171 config_path = components_dir / "pre_commit" / "files" / ".pre-commit-config.yaml.j2"
176- content = config_path .read_text (encoding = ' utf-8' )
172+ content = config_path .read_text (encoding = " utf-8" )
177173
178174 # Should include actionlint for GitHub Actions validation
179- assert ' actionlint' in content
180- assert ' rhysd/actionlint' in content
175+ assert " actionlint" in content
176+ assert " rhysd/actionlint" in content
0 commit comments