Skip to content

Commit 7bf6ee7

Browse files
authored
Test: path is trimmed when returned by the API (#9824)
This commit contains the test that was missing for my other PR: #9815 The test checks the commands' PATH are trimmed before being returned by the API.
1 parent 59cc7ec commit 7bf6ee7

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

readthedocs/rtd_tests/tests/test_api.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from allauth.socialaccount.models import SocialAccount
77
from django.contrib.auth.models import User
88
from django.http import QueryDict
9-
from django.test import TestCase
9+
from django.test import TestCase, override_settings
1010
from django.urls import reverse
1111
from django_dynamic_fixture import get
1212
from rest_framework import status
@@ -303,17 +303,20 @@ def test_response_building(self):
303303
self.assertEqual(build['success'], True)
304304
self.assertEqual(build['docs_url'], dashboard_url)
305305

306+
@override_settings(DOCROOT="/home/docs/checkouts/readthedocs.org/user_builds")
306307
def test_response_finished_and_success(self):
307308
"""The ``view docs`` attr should return a link to the docs."""
308309
client = APIClient()
309310
client.login(username='super', password='test')
310311
project = get(
311312
Project,
312-
language='en',
313+
language="en",
314+
slug="myproject",
313315
main_language_project=None,
314316
)
315317
version = get(
316318
Version,
319+
slug="myversion",
317320
project=project,
318321
built=True,
319322
uploaded=True,
@@ -325,6 +328,12 @@ def test_response_finished_and_success(self):
325328
state='finished',
326329
exit_code=0,
327330
)
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+
)
328337
resp = client.get('/api/v2/build/{build}/'.format(build=build.pk))
329338
self.assertEqual(resp.status_code, 200)
330339
build = resp.data
@@ -337,6 +346,11 @@ def test_response_finished_and_success(self):
337346
self.assertEqual(build['exit_code'], 0)
338347
self.assertEqual(build['success'], True)
339348
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+
)
340354

341355
def test_response_finished_and_fail(self):
342356
"""The ``view docs`` attr should return a link to the dashboard."""

0 commit comments

Comments
 (0)