From 4655e19f1acf3a548ee839637ad7cb9851a8455b Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Sun, 23 Feb 2014 23:02:30 +0000 Subject: [PATCH] Added some more wagtailadmin tests --- runtests.py | 3 +- wagtail/wagtailadmin/tests.py | 65 +++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/runtests.py b/runtests.py index d928654f55..578398059a 100755 --- a/runtests.py +++ b/runtests.py @@ -64,7 +64,8 @@ if not settings.configured: 'wagtail.wagtailsearch', 'wagtail.wagtailredirects', 'wagtail.tests', - ] + ], + WAGTAIL_SITE_NAME='Test Site' ) diff --git a/wagtail/wagtailadmin/tests.py b/wagtail/wagtailadmin/tests.py index bf0e4d60f4..620efb13fa 100644 --- a/wagtail/wagtailadmin/tests.py +++ b/wagtail/wagtailadmin/tests.py @@ -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) \ No newline at end of file