|
17 | 17 | from pre_commit.clientlib import MigrateShaToRev |
18 | 18 | from pre_commit.clientlib import OptionalSensibleRegexAtHook |
19 | 19 | from pre_commit.clientlib import OptionalSensibleRegexAtTop |
20 | | -from pre_commit.clientlib import validate_config_main |
21 | | -from pre_commit.clientlib import validate_manifest_main |
22 | 20 | from testing.fixtures import sample_local_config |
23 | 21 |
|
24 | 22 |
|
@@ -112,70 +110,6 @@ def test_config_schema_does_not_contain_defaults(): |
112 | 110 | assert not isinstance(item, cfgv.Optional) |
113 | 111 |
|
114 | 112 |
|
115 | | -def test_validate_manifest_main_ok(): |
116 | | - assert not validate_manifest_main(('.pre-commit-hooks.yaml',)) |
117 | | - |
118 | | - |
119 | | -def test_validate_config_main_ok(): |
120 | | - assert not validate_config_main(('.pre-commit-config.yaml',)) |
121 | | - |
122 | | - |
123 | | -def test_validate_warn_on_unknown_keys_at_repo_level(tmpdir, caplog): |
124 | | - f = tmpdir.join('cfg.yaml') |
125 | | - f.write( |
126 | | - 'repos:\n' |
127 | | - '- repo: https://gitlab.com/pycqa/flake8\n' |
128 | | - ' rev: 3.7.7\n' |
129 | | - ' hooks:\n' |
130 | | - ' - id: flake8\n' |
131 | | - ' args: [--some-args]\n', |
132 | | - ) |
133 | | - ret_val = validate_config_main((f.strpath,)) |
134 | | - assert not ret_val |
135 | | - assert caplog.record_tuples == [ |
136 | | - ( |
137 | | - 'pre_commit', |
138 | | - logging.WARNING, |
139 | | - 'pre-commit-validate-config is deprecated -- ' |
140 | | - 'use `pre-commit validate-config` instead.', |
141 | | - ), |
142 | | - ( |
143 | | - 'pre_commit', |
144 | | - logging.WARNING, |
145 | | - 'Unexpected key(s) present on https://gitlab.com/pycqa/flake8: ' |
146 | | - 'args', |
147 | | - ), |
148 | | - ] |
149 | | - |
150 | | - |
151 | | -def test_validate_warn_on_unknown_keys_at_top_level(tmpdir, caplog): |
152 | | - f = tmpdir.join('cfg.yaml') |
153 | | - f.write( |
154 | | - 'repos:\n' |
155 | | - '- repo: https://gitlab.com/pycqa/flake8\n' |
156 | | - ' rev: 3.7.7\n' |
157 | | - ' hooks:\n' |
158 | | - ' - id: flake8\n' |
159 | | - 'foo:\n' |
160 | | - ' id: 1.0.0\n', |
161 | | - ) |
162 | | - ret_val = validate_config_main((f.strpath,)) |
163 | | - assert not ret_val |
164 | | - assert caplog.record_tuples == [ |
165 | | - ( |
166 | | - 'pre_commit', |
167 | | - logging.WARNING, |
168 | | - 'pre-commit-validate-config is deprecated -- ' |
169 | | - 'use `pre-commit validate-config` instead.', |
170 | | - ), |
171 | | - ( |
172 | | - 'pre_commit', |
173 | | - logging.WARNING, |
174 | | - 'Unexpected key(s) present at root: foo', |
175 | | - ), |
176 | | - ] |
177 | | - |
178 | | - |
179 | 113 | def test_ci_map_key_allowed_at_top_level(caplog): |
180 | 114 | cfg = { |
181 | 115 | 'ci': {'skip': ['foo']}, |
@@ -362,18 +296,6 @@ def test_validate_optional_sensible_regex_at_top_level(caplog, regex, warning): |
362 | 296 | assert caplog.record_tuples == [('pre_commit', logging.WARNING, warning)] |
363 | 297 |
|
364 | 298 |
|
365 | | -@pytest.mark.parametrize('fn', (validate_config_main, validate_manifest_main)) |
366 | | -def test_mains_not_ok(tmpdir, fn): |
367 | | - not_yaml = tmpdir.join('f.notyaml') |
368 | | - not_yaml.write('{') |
369 | | - not_schema = tmpdir.join('notconfig.yaml') |
370 | | - not_schema.write('{}') |
371 | | - |
372 | | - assert fn(('does-not-exist',)) |
373 | | - assert fn((not_yaml.strpath,)) |
374 | | - assert fn((not_schema.strpath,)) |
375 | | - |
376 | | - |
377 | 299 | @pytest.mark.parametrize( |
378 | 300 | ('manifest_obj', 'expected'), |
379 | 301 | ( |
|
0 commit comments