-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Use querysets from the class not from an instance #5783
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5bcbbd8
Use querysets from the class not from an instance
stsewd 8808a6e
A test, of course
stsewd d7e228b
Increase expected query numbers
stsewd 394c2b3
Fix performance tests
stsewd 81fe011
Merge branch 'master' into use-querysets-as-expected
stsewd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
|
||
import os | ||
|
||
import django_dynamic_fixture as fixture | ||
import mock | ||
from django.conf import settings | ||
from django.contrib.auth.models import User | ||
from django.http import Http404 | ||
from django.http import Http404, HttpResponse | ||
from django.test import RequestFactory, TestCase | ||
from django.test.utils import override_settings | ||
from django.urls import reverse | ||
from mock import mock_open, patch | ||
|
||
from readthedocs.builds.constants import LATEST | ||
from readthedocs.builds.models import Version | ||
from readthedocs.core.middleware import SubdomainMiddleware | ||
from readthedocs.core.views import server_error_404_subdomain | ||
|
@@ -293,3 +293,39 @@ def test_sitemap_xml(self): | |
# hreflang should use hyphen instead of underscore | ||
# in language and country value. (zh_CN should be zh-CN) | ||
self.assertContains(response, 'zh-CN') | ||
|
||
@override_settings( | ||
PYTHON_MEDIA=True, | ||
USE_SUBDOMAIN=False, | ||
) | ||
@patch( | ||
'readthedocs.core.views.serve._serve_symlink_docs', | ||
new=mock.MagicMock(return_value=HttpResponse(content_type='text/html')), | ||
) | ||
def test_user_with_multiple_projects_serve_from_same_domain(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test case fails on master :) |
||
project = fixture.get( | ||
Project, | ||
main_language_project=None, | ||
users=[self.eric], | ||
) | ||
other_project = fixture.get( | ||
Project, | ||
main_language_project=None, | ||
users=[self.eric], | ||
) | ||
|
||
# Trigger the save method of the versions | ||
project.versions.get(slug=LATEST).save() | ||
other_project.versions.get(slug=LATEST).save() | ||
|
||
# Two projects of one owner with versions with the same slug | ||
self.assertIn(self.eric, project.users.all()) | ||
self.assertIn(self.eric, other_project.users.all()) | ||
self.assertTrue(project.versions.filter(slug=LATEST).exists()) | ||
self.assertTrue(other_project.versions.filter(slug=LATEST).exists()) | ||
|
||
self.client.force_login(self.eric) | ||
request = self.client.get( | ||
f'/docs/{project.slug}/en/latest/' | ||
) | ||
self.assertEqual(request.status_code, 200) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filter by active is the default in .org and .com querysets