forked from django/django
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Used a separate admin site for autocomplete tests.
- Loading branch information
Showing
2 changed files
with
7 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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,7 +1,6 @@ | ||
import json | ||
|
||
from django.contrib import admin | ||
from django.contrib.admin import site | ||
from django.contrib.admin.tests import AdminSeleniumTestCase | ||
from django.contrib.admin.views.autocomplete import AutocompleteJsonView | ||
from django.contrib.auth.models import Permission, User | ||
|
@@ -30,6 +29,7 @@ class BookAdmin(admin.ModelAdmin): | |
inlines = [AuthorshipInline] | ||
|
||
|
||
site = admin.AdminSite(name='autocomplete_admin') | ||
site.register(Question, QuestionAdmin) | ||
site.register(Answer, AnswerAdmin) | ||
site.register(Author, AuthorAdmin) | ||
|
@@ -39,7 +39,7 @@ class BookAdmin(admin.ModelAdmin): | |
class AutocompleteJsonViewTests(AdminViewBasicTestCase): | ||
as_view_args = {'model_admin': QuestionAdmin(Question, site)} | ||
factory = RequestFactory() | ||
url = reverse_lazy('admin:admin_views_question_autocomplete') | ||
url = reverse_lazy('autocomplete_admin:admin_views_question_autocomplete') | ||
|
||
@classmethod | ||
def setUpTestData(cls): | ||
|
@@ -156,12 +156,12 @@ def setUp(self): | |
self.superuser = User.objects.create_superuser( | ||
username='super', password='secret', email='[email protected]', | ||
) | ||
self.admin_login(username='super', password='secret', login_url=reverse('admin:index')) | ||
self.admin_login(username='super', password='secret', login_url=reverse('autocomplete_admin:index')) | ||
|
||
def test_select(self): | ||
from selenium.webdriver.common.keys import Keys | ||
from selenium.webdriver.support.ui import Select | ||
self.selenium.get(self.live_server_url + reverse('admin:admin_views_answer_add')) | ||
self.selenium.get(self.live_server_url + reverse('autocomplete_admin:admin_views_answer_add')) | ||
elem = self.selenium.find_element_by_css_selector('.select2-selection') | ||
elem.click() # Open the autocomplete dropdown. | ||
results = self.selenium.find_element_by_css_selector('.select2-results') | ||
|
@@ -196,7 +196,7 @@ def test_select(self): | |
def test_select_multiple(self): | ||
from selenium.webdriver.common.keys import Keys | ||
from selenium.webdriver.support.ui import Select | ||
self.selenium.get(self.live_server_url + reverse('admin:admin_views_question_add')) | ||
self.selenium.get(self.live_server_url + reverse('autocomplete_admin:admin_views_question_add')) | ||
elem = self.selenium.find_element_by_css_selector('.select2-selection') | ||
elem.click() # Open the autocomplete dropdown. | ||
results = self.selenium.find_element_by_css_selector('.select2-results') | ||
|
This file contains 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