Skip to content

Commit

Permalink
Test: path is trimmed when returned by the API (#9824)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
humitos authored Dec 21, 2022
1 parent 59cc7ec commit 7bf6ee7
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions readthedocs/rtd_tests/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from allauth.socialaccount.models import SocialAccount
from django.contrib.auth.models import User
from django.http import QueryDict
from django.test import TestCase
from django.test import TestCase, override_settings
from django.urls import reverse
from django_dynamic_fixture import get
from rest_framework import status
Expand Down Expand Up @@ -303,17 +303,20 @@ def test_response_building(self):
self.assertEqual(build['success'], True)
self.assertEqual(build['docs_url'], dashboard_url)

@override_settings(DOCROOT="/home/docs/checkouts/readthedocs.org/user_builds")
def test_response_finished_and_success(self):
"""The ``view docs`` attr should return a link to the docs."""
client = APIClient()
client.login(username='super', password='test')
project = get(
Project,
language='en',
language="en",
slug="myproject",
main_language_project=None,
)
version = get(
Version,
slug="myversion",
project=project,
built=True,
uploaded=True,
Expand All @@ -325,6 +328,12 @@ def test_response_finished_and_success(self):
state='finished',
exit_code=0,
)
buildcommandresult = get(
BuildCommandResult,
build=build,
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",
exit_code=0,
)
resp = client.get('/api/v2/build/{build}/'.format(build=build.pk))
self.assertEqual(resp.status_code, 200)
build = resp.data
Expand All @@ -337,6 +346,11 @@ def test_response_finished_and_success(self):
self.assertEqual(build['exit_code'], 0)
self.assertEqual(build['success'], True)
self.assertEqual(build['docs_url'], docs_url)
# Verify the path is trimmed
self.assertEqual(
build["commands"][0]["command"],
"python -m pip install --upgrade --no-cache-dir pip setuptools<58.3.0",
)

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

0 comments on commit 7bf6ee7

Please sign in to comment.