12
12
from readthedocs .builds .constants import EXTERNAL
13
13
from readthedocs .builds .models import Version
14
14
from readthedocs .config import ALL
15
+ from readthedocs .doc_builder .environments import LocalBuildEnvironment
15
16
from readthedocs .projects .exceptions import RepositoryError
16
17
from readthedocs .projects .models import Feature , Project
17
18
from readthedocs .rtd_tests .utils import (
@@ -45,6 +46,7 @@ def setUp(self):
45
46
# These are the default values from v1
46
47
self .dummy_conf .submodules .include = ALL
47
48
self .dummy_conf .submodules .exclude = []
49
+ self .build_environment = LocalBuildEnvironment ()
48
50
49
51
def test_git_lsremote (self ):
50
52
repo_path = self .project .repo
@@ -68,7 +70,7 @@ def test_git_lsremote(self):
68
70
create_git_tag (repo_path , 'v02' , annotated = True )
69
71
create_git_tag (repo_path , 'release-ünîø∂é' )
70
72
71
- repo = self .project .vcs_repo ()
73
+ repo = self .project .vcs_repo (environment = self . build_environment )
72
74
# create the working dir if it not exists. It's required to ``cwd`` to
73
75
# execute the command
74
76
repo .check_working_dir ()
@@ -91,7 +93,7 @@ def test_git_lsremote_tags_only(self):
91
93
create_git_tag (repo_path , "v02" , annotated = True )
92
94
create_git_tag (repo_path , "release-ünîø∂é" )
93
95
94
- repo = self .project .vcs_repo ()
96
+ repo = self .project .vcs_repo (environment = self . build_environment )
95
97
# create the working dir if it not exists. It's required to ``cwd`` to
96
98
# execute the command
97
99
repo .check_working_dir ()
@@ -123,7 +125,7 @@ def test_git_lsremote_branches_only(self):
123
125
for branch in branches :
124
126
create_git_branch (repo_path , branch )
125
127
126
- repo = self .project .vcs_repo ()
128
+ repo = self .project .vcs_repo (environment = self . build_environment )
127
129
# create the working dir if it not exists. It's required to ``cwd`` to
128
130
# execute the command
129
131
repo .check_working_dir ()
@@ -160,7 +162,7 @@ def test_git_branches(self, checkout_path):
160
162
os .mkdir (local_repo )
161
163
checkout_path .return_value = local_repo
162
164
163
- repo = self .project .vcs_repo ()
165
+ repo = self .project .vcs_repo (environment = self . build_environment )
164
166
repo .clone ()
165
167
166
168
self .assertEqual (
@@ -188,7 +190,7 @@ def test_git_branches_unicode(self, checkout_path):
188
190
os .mkdir (local_repo )
189
191
checkout_path .return_value = local_repo
190
192
191
- repo = self .project .vcs_repo ()
193
+ repo = self .project .vcs_repo (environment = self . build_environment )
192
194
repo .clone ()
193
195
194
196
self .assertEqual (
@@ -197,7 +199,7 @@ def test_git_branches_unicode(self, checkout_path):
197
199
)
198
200
199
201
def test_git_update_and_checkout (self ):
200
- repo = self .project .vcs_repo ()
202
+ repo = self .project .vcs_repo (environment = self . build_environment )
201
203
code , _ , _ = repo .update ()
202
204
self .assertEqual (code , 0 )
203
205
@@ -217,7 +219,8 @@ def test_git_update_with_external_version(self, fetch):
217
219
)
218
220
repo = self .project .vcs_repo (
219
221
verbose_name = version .verbose_name ,
220
- version_type = version .type
222
+ version_type = version .type ,
223
+ environment = self .build_environment ,
221
224
)
222
225
repo .update ()
223
226
fetch .assert_called_once ()
@@ -231,14 +234,15 @@ def test_git_fetch_with_external_version(self):
231
234
)
232
235
repo = self .project .vcs_repo (
233
236
verbose_name = version .verbose_name ,
234
- version_type = version .type
237
+ version_type = version .type ,
238
+ environment = self .build_environment ,
235
239
)
236
240
repo .update ()
237
241
code , _ , _ = repo .fetch ()
238
242
self .assertEqual (code , 0 )
239
243
240
244
def test_git_checkout_invalid_revision (self ):
241
- repo = self .project .vcs_repo ()
245
+ repo = self .project .vcs_repo (environment = self . build_environment )
242
246
repo .update ()
243
247
version = 'invalid-revision'
244
248
with self .assertRaises (RepositoryError ) as e :
@@ -253,7 +257,7 @@ def test_git_tags(self):
253
257
create_git_tag (repo_path , 'v01' )
254
258
create_git_tag (repo_path , 'v02' , annotated = True )
255
259
create_git_tag (repo_path , 'release-ünîø∂é' )
256
- repo = self .project .vcs_repo ()
260
+ repo = self .project .vcs_repo (environment = self . build_environment )
257
261
# We aren't cloning the repo,
258
262
# so we need to hack the repo path
259
263
repo .working_dir = repo_path
@@ -264,7 +268,7 @@ def test_git_tags(self):
264
268
)
265
269
266
270
def test_check_for_submodules (self ):
267
- repo = self .project .vcs_repo ()
271
+ repo = self .project .vcs_repo (environment = self . build_environment )
268
272
269
273
repo .update ()
270
274
self .assertFalse (repo .are_submodules_available (self .dummy_conf ))
@@ -274,13 +278,13 @@ def test_check_for_submodules(self):
274
278
self .assertTrue (repo .are_submodules_available (self .dummy_conf ))
275
279
276
280
def test_skip_submodule_checkout (self ):
277
- repo = self .project .vcs_repo ()
281
+ repo = self .project .vcs_repo (environment = self . build_environment )
278
282
repo .update ()
279
283
repo .checkout ('submodule' )
280
284
self .assertTrue (repo .are_submodules_available (self .dummy_conf ))
281
285
282
286
def test_use_shallow_clone (self ):
283
- repo = self .project .vcs_repo ()
287
+ repo = self .project .vcs_repo (environment = self . build_environment )
284
288
repo .update ()
285
289
repo .checkout ('submodule' )
286
290
self .assertTrue (repo .use_shallow_clone ())
@@ -293,14 +297,14 @@ def test_use_shallow_clone(self):
293
297
self .assertFalse (repo .use_shallow_clone ())
294
298
295
299
def test_check_submodule_urls (self ):
296
- repo = self .project .vcs_repo ()
300
+ repo = self .project .vcs_repo (environment = self . build_environment )
297
301
repo .update ()
298
302
repo .checkout ('submodule' )
299
303
valid , _ = repo .validate_submodules (self .dummy_conf )
300
304
self .assertTrue (valid )
301
305
302
306
def test_check_invalid_submodule_urls (self ):
303
- repo = self .project .vcs_repo ()
307
+ repo = self .project .vcs_repo (environment = self . build_environment )
304
308
repo .update ()
305
309
repo .checkout ('invalidsubmodule' )
306
310
with self .assertRaises (RepositoryError ) as e :
@@ -313,7 +317,7 @@ def test_check_invalid_submodule_urls(self):
313
317
)
314
318
315
319
def test_invalid_submodule_is_ignored (self ):
316
- repo = self .project .vcs_repo ()
320
+ repo = self .project .vcs_repo (environment = self . build_environment )
317
321
repo .update ()
318
322
repo .checkout ('submodule' )
319
323
gitmodules_path = os .path .join (repo .working_dir , '.gitmodules' )
@@ -341,7 +345,7 @@ def test_fetch_clean_tags_and_branches(self, checkout_path):
341
345
os .mkdir (local_repo )
342
346
checkout_path .return_value = local_repo
343
347
344
- repo = self .project .vcs_repo ()
348
+ repo = self .project .vcs_repo (environment = self . build_environment )
345
349
repo .clone ()
346
350
347
351
delete_git_tag (upstream_repo , 'v02' )
@@ -391,20 +395,25 @@ def setUp(self):
391
395
repo = hg_repo ,
392
396
)
393
397
self .project .users .add (self .eric )
398
+ self .build_environment = LocalBuildEnvironment ()
394
399
395
400
def test_parse_branches (self ):
396
401
data = """\
397
402
stable
398
403
default
399
404
"""
400
405
401
- expected_ids = ['stable' , 'default' ]
402
- given_ids = [x .identifier for x in
403
- self .project .vcs_repo ().parse_branches (data )]
406
+ expected_ids = ["stable" , "default" ]
407
+ given_ids = [
408
+ x .identifier
409
+ for x in self .project .vcs_repo (
410
+ environment = self .build_environment
411
+ ).parse_branches (data )
412
+ ]
404
413
self .assertEqual (expected_ids , given_ids )
405
414
406
415
def test_update_and_checkout (self ):
407
- repo = self .project .vcs_repo ()
416
+ repo = self .project .vcs_repo (environment = self . build_environment )
408
417
repo .make_clean_working_dir ()
409
418
code , _ , _ = repo .update ()
410
419
self .assertEqual (code , 0 )
@@ -413,7 +422,7 @@ def test_update_and_checkout(self):
413
422
self .assertTrue (exists (repo .working_dir ))
414
423
415
424
def test_checkout_invalid_revision (self ):
416
- repo = self .project .vcs_repo ()
425
+ repo = self .project .vcs_repo (environment = self . build_environment )
417
426
repo .update ()
418
427
version = 'invalid-revision'
419
428
with self .assertRaises (RepositoryError ) as e :
@@ -436,6 +445,10 @@ def test_parse_tags(self):
436
445
('2b2155623ee2' , '1.7.5' ),
437
446
]
438
447
439
- given_ids = [(x .identifier , x .verbose_name ) for x in
440
- self .project .vcs_repo ().parse_tags (data )]
448
+ given_ids = [
449
+ (x .identifier , x .verbose_name )
450
+ for x in self .project .vcs_repo (
451
+ environment = self .build_environment
452
+ ).parse_tags (data )
453
+ ]
441
454
self .assertEqual (expected_tags , given_ids )
0 commit comments