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
@@ -130,10 +127,7 @@ def test_load_empty_config_file(tmpdir):
130
127
def test_minimal_config (tmpdir ):
131
128
apply_fs (tmpdir , minimal_config_dir )
132
129
base = str (tmpdir )
133
- config = load (base , env_config )
134
- assert isinstance (config , ProjectConfig )
135
- assert len (config ) == 1
136
- build = config [0 ]
130
+ build = load (base , env_config )
137
131
assert isinstance (build , BuildConfigV1 )
138
132
139
133
@@ -144,10 +138,7 @@ def test_load_version1(tmpdir):
144
138
''' )
145
139
})
146
140
base = str (tmpdir )
147
- config = load (base , get_env_config ({'allow_v2' : True }))
148
- assert isinstance (config , ProjectConfig )
149
- assert len (config ) == 1
150
- build = config [0 ]
141
+ build = load (base , get_env_config ({'allow_v2' : True }))
151
142
assert isinstance (build , BuildConfigV1 )
152
143
153
144
@@ -158,10 +149,7 @@ def test_load_version2(tmpdir):
158
149
''' )
159
150
})
160
151
base = str (tmpdir )
161
- config = load (base , get_env_config ({'allow_v2' : True }))
162
- assert isinstance (config , ProjectConfig )
163
- assert len (config ) == 1
164
- build = config [0 ]
152
+ build = load (base , get_env_config ({'allow_v2' : True }))
165
153
assert isinstance (build , BuildConfigV2 )
166
154
167
155
@@ -182,31 +170,18 @@ def test_yaml_extension(tmpdir):
182
170
apply_fs (tmpdir , yaml_extension_config_dir )
183
171
base = str (tmpdir )
184
172
config = load (base , env_config )
185
- assert len (config ) == 1
173
+ assert isinstance (config , BuildConfigV1 )
186
174
187
175
188
176
def test_build_config_has_source_file (tmpdir ):
189
177
base = str (apply_fs (tmpdir , minimal_config_dir ))
190
- build = load (base , env_config )[ 0 ]
178
+ build = load (base , env_config )
191
179
assert build .source_file == os .path .join (base , 'readthedocs.yml' )
192
- assert build .source_position == 0
193
-
194
-
195
- def test_build_config_has_source_position (tmpdir ):
196
- base = str (apply_fs (tmpdir , multiple_config_dir ))
197
- builds = load (base , env_config )
198
- assert len (builds ) == 2
199
- first , second = filter (
200
- lambda b : not b .source_file .endswith ('nested/readthedocs.yml' ),
201
- builds ,
202
- )
203
- assert first .source_position == 0
204
- assert second .source_position == 1
205
180
206
181
207
182
def test_build_config_has_list_with_single_empty_value (tmpdir ):
208
183
base = str (apply_fs (tmpdir , config_with_explicit_empty_list ))
209
- build = load (base , env_config )[ 0 ]
184
+ build = load (base , env_config )
210
185
assert isinstance (build , BuildConfigV1 )
211
186
assert build .formats == []
212
187
@@ -216,7 +191,6 @@ def test_config_requires_name():
216
191
{'output_base' : '' },
217
192
{},
218
193
source_file = 'readthedocs.yml' ,
219
- source_position = 0 ,
220
194
)
221
195
with raises (InvalidConfig ) as excinfo :
222
196
build .validate ()
@@ -229,7 +203,6 @@ def test_build_requires_valid_name():
229
203
{'output_base' : '' },
230
204
{'name' : 'with/slashes' },
231
205
source_file = 'readthedocs.yml' ,
232
- source_position = 0 ,
233
206
)
234
207
with raises (InvalidConfig ) as excinfo :
235
208
build .validate ()
@@ -553,7 +526,6 @@ def test_valid_build_config():
553
526
env_config ,
554
527
minimal_config ,
555
528
source_file = 'readthedocs.yml' ,
556
- source_position = 0 ,
557
529
)
558
530
build .validate ()
559
531
assert build .name == 'docs'
@@ -575,7 +547,6 @@ def test_it_validates_to_abspath(self, tmpdir):
575
547
get_env_config (),
576
548
{'base' : '../docs' },
577
549
source_file = source_file ,
578
- source_position = 0 ,
579
550
)
580
551
build .validate ()
581
552
assert build .base == str (tmpdir .join ('docs' ))
@@ -596,7 +567,6 @@ def test_it_fails_if_base_is_not_a_string(self, tmpdir):
596
567
get_env_config (),
597
568
{'base' : 1 },
598
569
source_file = str (tmpdir .join ('readthedocs.yml' )),
599
- source_position = 0 ,
600
570
)
601
571
with raises (InvalidConfig ) as excinfo :
602
572
build .validate ()
@@ -609,7 +579,6 @@ def test_it_fails_if_base_does_not_exist(self, tmpdir):
609
579
get_env_config (),
610
580
{'base' : 'docs' },
611
581
source_file = str (tmpdir .join ('readthedocs.yml' )),
612
- source_position = 0 ,
613
582
)
614
583
with raises (InvalidConfig ) as excinfo :
615
584
build .validate ()
@@ -625,7 +594,6 @@ def test_it_fails_if_build_is_invalid_option(self, tmpdir):
625
594
get_env_config (),
626
595
{'build' : {'image' : 3.0 }},
627
596
source_file = str (tmpdir .join ('readthedocs.yml' )),
628
- source_position = 0 ,
629
597
)
630
598
with raises (InvalidConfig ) as excinfo :
631
599
build .validate ()
@@ -641,7 +609,6 @@ def test_it_fails_on_python_validation(self, tmpdir):
641
609
'python' : {'version' : '3.3' },
642
610
},
643
611
source_file = str (tmpdir .join ('readthedocs.yml' )),
644
- source_position = 0 ,
645
612
)
646
613
build .validate_build ()
647
614
with raises (InvalidConfig ) as excinfo :
@@ -658,7 +625,6 @@ def test_it_works_on_python_validation(self, tmpdir):
658
625
'python' : {'version' : '3.3' },
659
626
},
660
627
source_file = str (tmpdir .join ('readthedocs.yml' )),
661
- source_position = 0 ,
662
628
)
663
629
build .validate_build ()
664
630
build .validate_python ()
@@ -669,7 +635,6 @@ def test_it_works(self, tmpdir):
669
635
get_env_config (),
670
636
{'build' : {'image' : 'latest' }},
671
637
source_file = str (tmpdir .join ('readthedocs.yml' )),
672
- source_position = 0 ,
673
638
)
674
639
build .validate ()
675
640
assert build .build .image == 'readthedocs/build:latest'
@@ -680,7 +645,6 @@ def test_default(self, tmpdir):
680
645
get_env_config (),
681
646
{},
682
647
source_file = str (tmpdir .join ('readthedocs.yml' )),
683
- source_position = 0 ,
684
648
)
685
649
build .validate ()
686
650
assert build .build .image == 'readthedocs/build:2.0'
@@ -696,7 +660,6 @@ def test_it_priorities_image_from_env_config(self, tmpdir, image):
696
660
get_env_config ({'defaults' : defaults }),
697
661
{'build' : {'image' : 'latest' }},
698
662
source_file = str (tmpdir .join ('readthedocs.yml' )),
699
- source_position = 0 ,
700
663
)
701
664
build .validate ()
702
665
assert build .build .image == image
@@ -786,7 +749,6 @@ def test_build_validate_calls_all_subvalidators(tmpdir):
786
749
{},
787
750
{},
788
751
source_file = str (tmpdir .join ('readthedocs.yml' )),
789
- source_position = 0 ,
790
752
)
791
753
with patch .multiple (
792
754
BuildConfigV1 ,
@@ -802,20 +764,6 @@ def test_build_validate_calls_all_subvalidators(tmpdir):
802
764
BuildConfigV1 .validate_output_base .assert_called_with ()
803
765
804
766
805
- def test_validate_project_config ():
806
- with patch .object (BuildConfigV1 , 'validate' ) as build_validate :
807
- project = ProjectConfig ([
808
- BuildConfigV1 (
809
- env_config ,
810
- minimal_config ,
811
- source_file = 'readthedocs.yml' ,
812
- source_position = 0 ,
813
- ),
814
- ])
815
- project .validate ()
816
- assert build_validate .call_count == 1
817
-
818
-
819
767
def test_load_calls_validate (tmpdir ):
820
768
apply_fs (tmpdir , minimal_config_dir )
821
769
base = str (tmpdir )
@@ -896,13 +844,12 @@ def test_as_dict(tmpdir):
896
844
897
845
class TestBuildConfigV2 (object ):
898
846
899
- def get_build_config (self , config , env_config = None ,
900
- source_file = 'readthedocs.yml' , source_position = 0 ):
847
+ def get_build_config (
848
+ self , config , env_config = None , source_file = 'readthedocs.yml' ):
901
849
return BuildConfigV2 (
902
850
env_config or {},
903
851
config ,
904
852
source_file = source_file ,
905
- source_position = source_position ,
906
853
)
907
854
908
855
def test_version (self ):
0 commit comments