Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test: path is trimmed when returned by the API #9824

Merged
merged 1 commit into from
Dec 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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