88
99from mergify_cli .ci .scopes import base_detector
1010from mergify_cli .ci .scopes import cli
11+ from mergify_cli .ci .scopes import config
1112
1213
1314def test_from_yaml_with_extras_ignored (tmp_path : pathlib .Path ) -> None :
@@ -32,8 +33,8 @@ def test_from_yaml_with_extras_ignored(tmp_path: pathlib.Path) -> None:
3233 ),
3334 )
3435
35- config = cli .Config .from_yaml (str (config_file ))
36- assert config .model_dump () == {
36+ cfg = config .Config .from_yaml (str (config_file ))
37+ assert cfg .model_dump () == {
3738 "scopes" : {
3839 "source" : {
3940 "files" : {
@@ -71,8 +72,8 @@ def test_from_yaml_valid(tmp_path: pathlib.Path) -> None:
7172 ),
7273 )
7374
74- config = cli .Config .from_yaml (str (config_file ))
75- assert config .model_dump () == {
75+ cfg = config .Config .from_yaml (str (config_file ))
76+ assert cfg .model_dump () == {
7677 "scopes" : {
7778 "merge_queue_scope" : "merge-queue" ,
7879 "source" : {
@@ -99,12 +100,12 @@ def test_from_yaml_invalid_config(tmp_path: pathlib.Path) -> None:
99100 )
100101
101102 # Bad name and missing dict
102- with pytest .raises (cli .ConfigInvalidError , match = "3 validation errors" ):
103- cli .Config .from_yaml (str (config_file ))
103+ with pytest .raises (config .ConfigInvalidError , match = "3 validation errors" ):
104+ config .Config .from_yaml (str (config_file ))
104105
105106
106107def test_match_scopes_basic () -> None :
107- config = cli .Config .from_dict (
108+ cfg = config .Config .from_dict (
108109 {
109110 "scopes" : {
110111 "source" : {
@@ -119,9 +120,9 @@ def test_match_scopes_basic() -> None:
119120 )
120121 files = ["api/models.py" , "ui/components/Button.tsx" , "README.md" , "other.txt" ]
121122
122- assert config .scopes .source is not None
123- assert isinstance (config .scopes .source , cli .SourceFiles )
124- scopes_hit , per_scope = cli .match_scopes (files , config .scopes .source .files )
123+ assert cfg .scopes .source is not None
124+ assert isinstance (cfg .scopes .source , config .SourceFiles )
125+ scopes_hit , per_scope = cli .match_scopes (files , cfg .scopes .source .files )
125126
126127 assert scopes_hit == {"backend" , "frontend" , "docs" }
127128 assert per_scope == {
@@ -132,7 +133,7 @@ def test_match_scopes_basic() -> None:
132133
133134
134135def test_match_scopes_no_matches () -> None :
135- config = cli .Config .from_dict (
136+ cfg = config .Config .from_dict (
136137 {
137138 "scopes" : {
138139 "source" : {
@@ -146,16 +147,16 @@ def test_match_scopes_no_matches() -> None:
146147 )
147148 files = ["other.txt" , "unrelated.cpp" ]
148149
149- assert config .scopes .source is not None
150- assert isinstance (config .scopes .source , cli .SourceFiles )
151- scopes_hit , per_scope = cli .match_scopes (files , config .scopes .source .files )
150+ assert cfg .scopes .source is not None
151+ assert isinstance (cfg .scopes .source , config .SourceFiles )
152+ scopes_hit , per_scope = cli .match_scopes (files , cfg .scopes .source .files )
152153
153154 assert scopes_hit == set ()
154155 assert per_scope == {}
155156
156157
157158def test_match_scopes_multiple_include_single_scope () -> None :
158- config = cli .Config .from_dict (
159+ cfg = config .Config .from_dict (
159160 {
160161 "scopes" : {
161162 "source" : {
@@ -168,9 +169,9 @@ def test_match_scopes_multiple_include_single_scope() -> None:
168169 )
169170 files = ["api/models.py" , "backend/services.py" ]
170171
171- assert config .scopes .source is not None
172- assert isinstance (config .scopes .source , cli .SourceFiles )
173- scopes_hit , per_scope = cli .match_scopes (files , config .scopes .source .files )
172+ assert cfg .scopes .source is not None
173+ assert isinstance (cfg .scopes .source , config .SourceFiles )
174+ scopes_hit , per_scope = cli .match_scopes (files , cfg .scopes .source .files )
174175
175176 assert scopes_hit == {"backend" }
176177 assert per_scope == {
@@ -179,7 +180,7 @@ def test_match_scopes_multiple_include_single_scope() -> None:
179180
180181
181182def test_match_scopes_with_negation_include () -> None :
182- config = cli .Config .from_dict (
183+ cfg = config .Config .from_dict (
183184 {
184185 "scopes" : {
185186 "source" : {
@@ -204,9 +205,9 @@ def test_match_scopes_with_negation_include() -> None:
204205 "ui/components.spec.js" ,
205206 ]
206207
207- assert config .scopes .source is not None
208- assert isinstance (config .scopes .source , cli .SourceFiles )
209- scopes_hit , per_scope = cli .match_scopes (files , config .scopes .source .files )
208+ assert cfg .scopes .source is not None
209+ assert isinstance (cfg .scopes .source , config .SourceFiles )
210+ scopes_hit , per_scope = cli .match_scopes (files , cfg .scopes .source .files )
210211
211212 assert scopes_hit == {"backend" , "frontend" }
212213 assert per_scope == {
@@ -216,7 +217,7 @@ def test_match_scopes_with_negation_include() -> None:
216217
217218
218219def test_match_scopes_negation_only () -> None :
219- config = cli .Config .from_dict (
220+ cfg = config .Config .from_dict (
220221 {
221222 "scopes" : {
222223 "source" : {
@@ -232,9 +233,9 @@ def test_match_scopes_negation_only() -> None:
232233 )
233234 files = ["image.jpeg" , "document.txt" , "photo.png" , "readme.md" ]
234235
235- assert config .scopes .source is not None
236- assert isinstance (config .scopes .source , cli .SourceFiles )
237- scopes_hit , per_scope = cli .match_scopes (files , config .scopes .source .files )
236+ assert cfg .scopes .source is not None
237+ assert isinstance (cfg .scopes .source , config .SourceFiles )
238+ scopes_hit , per_scope = cli .match_scopes (files , cfg .scopes .source .files )
238239
239240 assert scopes_hit == {"exclude_images" }
240241 assert per_scope == {
@@ -243,7 +244,7 @@ def test_match_scopes_negation_only() -> None:
243244
244245
245246def test_match_scopes_mixed_with_complex_negation () -> None :
246- config = cli .Config .from_dict (
247+ cfg = config .Config .from_dict (
247248 {
248249 "scopes" : {
249250 "source" : {
@@ -265,9 +266,9 @@ def test_match_scopes_mixed_with_complex_negation() -> None:
265266 "main.py" ,
266267 ]
267268
268- assert config .scopes .source is not None
269- assert isinstance (config .scopes .source , cli .SourceFiles )
270- scopes_hit , per_scope = cli .match_scopes (files , config .scopes .source .files )
269+ assert cfg .scopes .source is not None
270+ assert isinstance (cfg .scopes .source , config .SourceFiles )
271+ scopes_hit , per_scope = cli .match_scopes (files , cfg .scopes .source .files )
271272
272273 assert scopes_hit == {"backend" }
273274 assert per_scope == {
0 commit comments