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