6
6
from allauth .socialaccount .models import SocialAccount
7
7
from django .contrib .auth .models import User
8
8
from django .http import QueryDict
9
- from django .test import TestCase
9
+ from django .test import TestCase , override_settings
10
10
from django .urls import reverse
11
11
from django_dynamic_fixture import get
12
12
from rest_framework import status
@@ -303,17 +303,20 @@ def test_response_building(self):
303
303
self .assertEqual (build ['success' ], True )
304
304
self .assertEqual (build ['docs_url' ], dashboard_url )
305
305
306
+ @override_settings (DOCROOT = "/home/docs/checkouts/readthedocs.org/user_builds" )
306
307
def test_response_finished_and_success (self ):
307
308
"""The ``view docs`` attr should return a link to the docs."""
308
309
client = APIClient ()
309
310
client .login (username = 'super' , password = 'test' )
310
311
project = get (
311
312
Project ,
312
- language = 'en' ,
313
+ language = "en" ,
314
+ slug = "myproject" ,
313
315
main_language_project = None ,
314
316
)
315
317
version = get (
316
318
Version ,
319
+ slug = "myversion" ,
317
320
project = project ,
318
321
built = True ,
319
322
uploaded = True ,
@@ -325,6 +328,12 @@ def test_response_finished_and_success(self):
325
328
state = 'finished' ,
326
329
exit_code = 0 ,
327
330
)
331
+ buildcommandresult = get (
332
+ BuildCommandResult ,
333
+ build = build ,
334
+ command = "/home/docs/checkouts/readthedocs.org/user_builds/myproject/envs/myversion/bin/python -m pip install --upgrade --no-cache-dir pip setuptools<58.3.0" ,
335
+ exit_code = 0 ,
336
+ )
328
337
resp = client .get ('/api/v2/build/{build}/' .format (build = build .pk ))
329
338
self .assertEqual (resp .status_code , 200 )
330
339
build = resp .data
@@ -337,6 +346,11 @@ def test_response_finished_and_success(self):
337
346
self .assertEqual (build ['exit_code' ], 0 )
338
347
self .assertEqual (build ['success' ], True )
339
348
self .assertEqual (build ['docs_url' ], docs_url )
349
+ # Verify the path is trimmed
350
+ self .assertEqual (
351
+ build ["commands" ][0 ]["command" ],
352
+ "python -m pip install --upgrade --no-cache-dir pip setuptools<58.3.0" ,
353
+ )
340
354
341
355
def test_response_finished_and_fail (self ):
342
356
"""The ``view docs`` attr should return a link to the dashboard."""
0 commit comments