mirror of
https://github.com/wagtail/wagtail.git
synced 2024-11-24 10:58:52 +01:00
Added some more wagtailadmin tests
This commit is contained in:
parent
c981e33367
commit
4655e19f1a
@ -64,7 +64,8 @@ if not settings.configured:
|
||||
'wagtail.wagtailsearch',
|
||||
'wagtail.wagtailredirects',
|
||||
'wagtail.tests',
|
||||
]
|
||||
],
|
||||
WAGTAIL_SITE_NAME='Test Site'
|
||||
)
|
||||
|
||||
|
||||
|
@ -6,6 +6,16 @@ from wagtail.wagtailcore.models import Page
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
|
||||
class TestHome(TestCase):
|
||||
def setUp(self):
|
||||
# Login
|
||||
login(self.client)
|
||||
|
||||
def test_status_code(self):
|
||||
response = self.client.get(reverse('wagtailadmin_home'))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
class TestPageExplorer(TestCase):
|
||||
def setUp(self):
|
||||
# Find root page
|
||||
@ -102,6 +112,23 @@ class TestPageSearch(TestCase):
|
||||
# Login
|
||||
login(self.client)
|
||||
|
||||
def get(self, params={}):
|
||||
return self.client.get(reverse('wagtailadmin_pages_search'), params)
|
||||
|
||||
def test_status_code(self):
|
||||
self.assertEqual(self.get().status_code, 200)
|
||||
|
||||
def test_search(self):
|
||||
response = self.get({'q': "Hello"})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.context['search_query'], "Hello")
|
||||
|
||||
def test_pagination(self):
|
||||
pages = ['0', '1', '-1', '9999', 'Not a page']
|
||||
for page in pages:
|
||||
response = self.get({'p': page})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_root_can_appear_in_search_results(self):
|
||||
response = self.client.get('/admin/pages/search/?q=roo')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
@ -109,3 +136,41 @@ class TestPageSearch(TestCase):
|
||||
results = response.context['pages']
|
||||
self.assertTrue(any([r.slug == 'root' for r in results]))
|
||||
|
||||
|
||||
class TestPageMove(TestCase):
|
||||
def setUp(self):
|
||||
# Find root page
|
||||
self.root_page = Page.objects.get(id=2)
|
||||
|
||||
# Create two sections
|
||||
self.section_a = EventPage()
|
||||
self.section_a.title = "Section A"
|
||||
self.section_a.slug = "section-a"
|
||||
self.root_page.add_child(self.section_a)
|
||||
|
||||
self.section_b = EventPage()
|
||||
self.section_b.title = "Section B"
|
||||
self.section_b.slug = "section-b"
|
||||
self.root_page.add_child(self.section_b)
|
||||
|
||||
# Add test page into section A
|
||||
self.test_page = EventPage()
|
||||
self.test_page.title = "Hello world!"
|
||||
self.test_page.slug = "hello-world"
|
||||
self.section_a.add_child(self.test_page)
|
||||
|
||||
# Login
|
||||
login(self.client)
|
||||
|
||||
@unittest.expectedFailure # TODO: Fix crash
|
||||
def test_page_move(self):
|
||||
response = self.client.get(reverse('wagtailadmin_pages_move', args=(self.test_page.id, )))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_page_move_confirm(self):
|
||||
response = self.client.get(reverse('wagtailadmin_pages_move_confirm', args=(self.test_page.id, self.section_b.id)))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_page_set_page_position(self):
|
||||
response = self.client.get(reverse('wagtailadmin_pages_set_page_position', args=(self.test_page.id, )))
|
||||
self.assertEqual(response.status_code, 200)
|
Loading…
Reference in New Issue
Block a user