Skip to content

Commit

Permalink
Update tests with new Version.get_absolute_url implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaoming committed May 31, 2023
1 parent a485f83 commit 1b1d9fe
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
30 changes: 20 additions & 10 deletions readthedocs/rtd_tests/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import dateutil
from allauth.socialaccount.models import SocialAccount
from django.contrib.auth.models import User
from django.core.validators import URLValidator
from django.http import QueryDict
from django.test import TestCase, override_settings
from django.urls import reverse
Expand Down Expand Up @@ -299,12 +300,17 @@ def test_response_building(self):
'version_slug': version.slug,
},
)

build = resp.data
self.assertEqual(build['state'], 'cloning')
self.assertEqual(build['error'], '')
self.assertEqual(build['exit_code'], 0)
self.assertEqual(build['success'], True)
self.assertEqual(build['docs_url'], dashboard_url)
self.assertEqual(build["state"], "cloning")
self.assertEqual(build["error"], "")
self.assertEqual(build["exit_code"], 0)
self.assertEqual(build["success"], True)
self.assertTrue(build["docs_url"].endswith(dashboard_url))

# Validate received URL (fails with ValidationError if incorrect value)
url_validator = URLValidator(schemes=["https"])
url_validator(build["docs_url"])

@override_settings(DOCROOT="/home/docs/checkouts/readthedocs.org/user_builds")
def test_response_finished_and_success(self):
Expand Down Expand Up @@ -390,11 +396,15 @@ def test_response_finished_and_fail(self):
},
)
build = resp.data
self.assertEqual(build['state'], 'finished')
self.assertEqual(build['error'], '')
self.assertEqual(build['exit_code'], 1)
self.assertEqual(build['success'], False)
self.assertEqual(build['docs_url'], dashboard_url)
self.assertEqual(build["state"], "finished")
self.assertEqual(build["error"], "")
self.assertEqual(build["exit_code"], 1)
self.assertEqual(build["success"], False)
self.assertTrue(build["docs_url"].endswith(dashboard_url))

# Validate received URL (fails with ValidationError if incorrect value)
url_validator = URLValidator(schemes=["https"])
url_validator(build["docs_url"])

def test_make_build_without_permission(self):
"""Ensure anonymous/non-staff users cannot write the build endpoint."""
Expand Down
2 changes: 2 additions & 0 deletions readthedocs/rtd_tests/tests/test_oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ def test_send_build_status_value_error(self, session, mock_logger):
commit_status='success',
user_username=self.user.username,
statuses_url='https://api.github.com/repos/pypa/pip/statuses/1234',
target_url=mock.ANY,
status="success",
)
mock_logger.exception.assert_called_with(
'GitHub commit status creation failed for project.',
Expand Down

0 comments on commit 1b1d9fe

Please sign in to comment.