17
17
ConfigError ,
18
18
ConfigOptionNotSupportedError ,
19
19
InvalidConfig ,
20
- ProjectConfig ,
21
20
load ,
22
21
)
23
22
from readthedocs .config .config import (
81
80
}
82
81
83
82
84
- def get_build_config (config , env_config = None , source_file = 'readthedocs.yml' ,
85
- source_position = 0 ):
83
+ def get_build_config (config , env_config = None , source_file = 'readthedocs.yml' ):
86
84
return BuildConfigV1 (
87
85
env_config or {},
88
86
config ,
89
87
source_file = source_file ,
90
- source_position = source_position ,
91
88
)
92
89
93
90
@@ -131,10 +128,7 @@ def test_load_empty_config_file(tmpdir):
131
128
def test_minimal_config (tmpdir ):
132
129
apply_fs (tmpdir , minimal_config_dir )
133
130
base = str (tmpdir )
134
- config = load (base , env_config )
135
- assert isinstance (config , ProjectConfig )
136
- assert len (config ) == 1
137
- build = config [0 ]
131
+ build = load (base , env_config )
138
132
assert isinstance (build , BuildConfigV1 )
139
133
140
134
@@ -145,10 +139,7 @@ def test_load_version1(tmpdir):
145
139
''' )
146
140
})
147
141
base = str (tmpdir )
148
- config = load (base , get_env_config ({'allow_v2' : True }))
149
- assert isinstance (config , ProjectConfig )
150
- assert len (config ) == 1
151
- build = config [0 ]
142
+ build = load (base , get_env_config ({'allow_v2' : True }))
152
143
assert isinstance (build , BuildConfigV1 )
153
144
154
145
@@ -159,10 +150,7 @@ def test_load_version2(tmpdir):
159
150
''' )
160
151
})
161
152
base = str (tmpdir )
162
- config = load (base , get_env_config ({'allow_v2' : True }))
163
- assert isinstance (config , ProjectConfig )
164
- assert len (config ) == 1
165
- build = config [0 ]
153
+ build = load (base , get_env_config ({'allow_v2' : True }))
166
154
assert isinstance (build , BuildConfigV2 )
167
155
168
156
@@ -183,31 +171,18 @@ def test_yaml_extension(tmpdir):
183
171
apply_fs (tmpdir , yaml_extension_config_dir )
184
172
base = str (tmpdir )
185
173
config = load (base , env_config )
186
- assert len (config ) == 1
174
+ assert isinstance (config , BuildConfigV1 )
187
175
188
176
189
177
def test_build_config_has_source_file (tmpdir ):
190
178
base = str (apply_fs (tmpdir , minimal_config_dir ))
191
- build = load (base , env_config )[ 0 ]
179
+ build = load (base , env_config )
192
180
assert build .source_file == os .path .join (base , 'readthedocs.yml' )
193
- assert build .source_position == 0
194
-
195
-
196
- def test_build_config_has_source_position (tmpdir ):
197
- base = str (apply_fs (tmpdir , multiple_config_dir ))
198
- builds = load (base , env_config )
199
- assert len (builds ) == 2
200
- first , second = filter (
201
- lambda b : not b .source_file .endswith ('nested/readthedocs.yml' ),
202
- builds ,
203
- )
204
- assert first .source_position == 0
205
- assert second .source_position == 1
206
181
207
182
208
183
def test_build_config_has_list_with_single_empty_value (tmpdir ):
209
184
base = str (apply_fs (tmpdir , config_with_explicit_empty_list ))
210
- build = load (base , env_config )[ 0 ]
185
+ build = load (base , env_config )
211
186
assert isinstance (build , BuildConfigV1 )
212
187
assert build .formats == []
213
188
@@ -217,7 +192,6 @@ def test_config_requires_name():
217
192
{'output_base' : '' },
218
193
{},
219
194
source_file = 'readthedocs.yml' ,
220
- source_position = 0 ,
221
195
)
222
196
with raises (InvalidConfig ) as excinfo :
223
197
build .validate ()
@@ -230,7 +204,6 @@ def test_build_requires_valid_name():
230
204
{'output_base' : '' },
231
205
{'name' : 'with/slashes' },
232
206
source_file = 'readthedocs.yml' ,
233
- source_position = 0 ,
234
207
)
235
208
with raises (InvalidConfig ) as excinfo :
236
209
build .validate ()
@@ -554,7 +527,6 @@ def test_valid_build_config():
554
527
env_config ,
555
528
minimal_config ,
556
529
source_file = 'readthedocs.yml' ,
557
- source_position = 0 ,
558
530
)
559
531
build .validate ()
560
532
assert build .name == 'docs'
@@ -576,7 +548,6 @@ def it_validates_to_abspath(tmpdir):
576
548
get_env_config (),
577
549
{'base' : '../docs' },
578
550
source_file = source_file ,
579
- source_position = 0 ,
580
551
)
581
552
build .validate ()
582
553
assert build .base == str (tmpdir .join ('docs' ))
@@ -597,7 +568,6 @@ def it_fails_if_base_is_not_a_string(tmpdir):
597
568
get_env_config (),
598
569
{'base' : 1 },
599
570
source_file = str (tmpdir .join ('readthedocs.yml' )),
600
- source_position = 0 ,
601
571
)
602
572
with raises (InvalidConfig ) as excinfo :
603
573
build .validate ()
@@ -610,7 +580,6 @@ def it_fails_if_base_does_not_exist(tmpdir):
610
580
get_env_config (),
611
581
{'base' : 'docs' },
612
582
source_file = str (tmpdir .join ('readthedocs.yml' )),
613
- source_position = 0 ,
614
583
)
615
584
with raises (InvalidConfig ) as excinfo :
616
585
build .validate ()
@@ -626,7 +595,6 @@ def it_fails_if_build_is_invalid_option(tmpdir):
626
595
get_env_config (),
627
596
{'build' : {'image' : 3.0 }},
628
597
source_file = str (tmpdir .join ('readthedocs.yml' )),
629
- source_position = 0 ,
630
598
)
631
599
with raises (InvalidConfig ) as excinfo :
632
600
build .validate ()
@@ -642,7 +610,6 @@ def it_fails_on_python_validation(tmpdir):
642
610
'python' : {'version' : '3.3' },
643
611
},
644
612
source_file = str (tmpdir .join ('readthedocs.yml' )),
645
- source_position = 0 ,
646
613
)
647
614
build .validate_build ()
648
615
with raises (InvalidConfig ) as excinfo :
@@ -659,7 +626,6 @@ def it_works_on_python_validation(tmpdir):
659
626
'python' : {'version' : '3.3' },
660
627
},
661
628
source_file = str (tmpdir .join ('readthedocs.yml' )),
662
- source_position = 0 ,
663
629
)
664
630
build .validate_build ()
665
631
build .validate_python ()
@@ -670,7 +636,6 @@ def it_works(tmpdir):
670
636
get_env_config (),
671
637
{'build' : {'image' : 'latest' }},
672
638
source_file = str (tmpdir .join ('readthedocs.yml' )),
673
- source_position = 0 ,
674
639
)
675
640
build .validate ()
676
641
assert build .build .image == 'readthedocs/build:latest'
@@ -681,7 +646,6 @@ def default(tmpdir):
681
646
get_env_config (),
682
647
{},
683
648
source_file = str (tmpdir .join ('readthedocs.yml' )),
684
- source_position = 0 ,
685
649
)
686
650
build .validate ()
687
651
assert build .build .image == 'readthedocs/build:2.0'
@@ -697,7 +661,6 @@ def it_priorities_image_from_env_config(tmpdir, image):
697
661
get_env_config ({'defaults' : defaults }),
698
662
{'build' : {'image' : 'latest' }},
699
663
source_file = str (tmpdir .join ('readthedocs.yml' )),
700
- source_position = 0 ,
701
664
)
702
665
build .validate ()
703
666
assert build .build .image == image
@@ -787,7 +750,6 @@ def test_build_validate_calls_all_subvalidators(tmpdir):
787
750
{},
788
751
{},
789
752
source_file = str (tmpdir .join ('readthedocs.yml' )),
790
- source_position = 0 ,
791
753
)
792
754
with patch .multiple (
793
755
BuildConfigV1 ,
@@ -803,20 +765,6 @@ def test_build_validate_calls_all_subvalidators(tmpdir):
803
765
BuildConfigV1 .validate_output_base .assert_called_with ()
804
766
805
767
806
- def test_validate_project_config ():
807
- with patch .object (BuildConfigV1 , 'validate' ) as build_validate :
808
- project = ProjectConfig ([
809
- BuildConfigV1 (
810
- env_config ,
811
- minimal_config ,
812
- source_file = 'readthedocs.yml' ,
813
- source_position = 0 ,
814
- ),
815
- ])
816
- project .validate ()
817
- assert build_validate .call_count == 1
818
-
819
-
820
768
def test_load_calls_validate (tmpdir ):
821
769
apply_fs (tmpdir , minimal_config_dir )
822
770
base = str (tmpdir )
@@ -844,12 +792,11 @@ def test_config_filenames_regex(correct_config_filename):
844
792
class TestBuildConfigV2 (object ):
845
793
846
794
def get_build_config (self , config , env_config = None ,
847
- source_file = 'readthedocs.yml' , source_position = 0 ):
795
+ source_file = 'readthedocs.yml' ):
848
796
return BuildConfigV2 (
849
797
env_config or {},
850
798
config ,
851
799
source_file = source_file ,
852
- source_position = source_position ,
853
800
)
854
801
855
802
def test_version (self ):
0 commit comments