~netlandish/django-wiki

5ff400434a429ef5066193bb0b39b953456a98ee — Benjamin Bach 4 years ago eec1e33
Add tests for DirView
1 files changed, 41 insertions(+), 1 deletions(-)

M tests/core/test_views.py
M tests/core/test_views.py => tests/core/test_views.py +41 -1
@@ 684,6 684,7 @@ class SourceViewTests(RequireRootArticleMixin, ArticleWebTestUtils, DjangoClient


class HistoryViewTests(RequireRootArticleMixin, ArticleWebTestUtils, DjangoClientTestBase):

    def test_can_read_permission(self):
        response = self.client.get(reverse('wiki:history', kwargs={
            'article_id': self.root_article.pk,


@@ 694,11 695,50 @@ class HistoryViewTests(RequireRootArticleMixin, ArticleWebTestUtils, DjangoClien
        response = self.client.get(reverse('wiki:history', kwargs={
            'article_id': self.root_article.pk,
        }))
        self.assertIn('History:', str(response.content))
        self.assertContains(response, 'History:')
        self.assertEqual(response.context['selected_tab'], 'history')


class DirViewTests(RequireRootArticleMixin, ArticleWebTestUtils, DjangoClientTestBase):

    def test_browse_root(self):
        response = self.client.get(
            reverse('wiki:dir', kwargs={'path': ''}),
        )
        self.assertRegex(
            response.rendered_content,
            r'Browsing\s+<strong><a href=".+">/</a></strong>'
        )

    def test_browse_root_query(self):
        self.client.post(
            resolve_url('wiki:create', path=''),
            {'title': 'Test', 'slug': 'test0', 'content': 'Content .0.'}
        )
        self.client.post(
            resolve_url('wiki:create', path='test0/'),
            {'title': 'Test00', 'slug': 'test00', 'content': 'Content .00.'}
        )
        response = self.client.get(
            reverse('wiki:dir', kwargs={'path': ''}),
            {'query': "Test"},
        )
        self.assertRegex(
            response.rendered_content,
            r'1 article'
        )
        response = self.client.get(
            reverse('wiki:dir', kwargs={'path': 'test0/'}),
            {'query': "Test00"},
        )
        self.assertRegex(
            response.rendered_content,
            r'1 article'
        )


class SettingsViewTests(RequireRootArticleMixin, ArticleWebTestUtils, DjangoClientTestBase):

    def test_change_group(self):
        group = CustomGroup.objects.create()
        response = self.client.post(