~netlandish/django-wiki

1dc7353c392dae793fe2854c148c898f138e8ece — Benjamin Bach 7 years ago 393af48
Add test of merge preview
2 files changed, 52 insertions(+), 0 deletions(-)

M .gitignore
M wiki/tests/test_views.py
M .gitignore => .gitignore +3 -0
@@ 14,6 14,9 @@ wiki/attachments
#PyCharm
.idea

# Test artifacts
cache
wiki/images

#Docs
docs/_build

M wiki/tests/test_views.py => wiki/tests/test_views.py +49 -0
@@ 3,6 3,7 @@ from __future__ import absolute_import, print_function, unicode_literals
import pprint

from django.contrib.auth import authenticate
from wiki import models
from wiki.models import reverse

from .base import ArticleWebTestBase, WebTestBase


@@ 345,3 346,51 @@ class UpdateProfileViewTest(ArticleWebTestBase):

        self.assertNotEqual(test_auth, None)
        self.assertEqual(test_auth.email, 'test@test.com')


class MergeViewTest(ArticleWebTestBase):

    def test_merge_preview(self):
        """Test merge preview"""

        c = self.c
        example_data = {
            'content': 'More modifications\n\nMerge new line',
            'current_revision': '1',
            'preview': '0',
            'save': '1',
            'summary': 'testing merge',
            'title': 'wiki test'
        }

        previous_revision = self.root_article.current_revision.id

        # save a new revision
        c.post(
            reverse('wiki:edit', kwargs={'path': ''}),
            example_data
        )

        response = c.get(
            reverse(
                'wiki:merge_revision_preview',
                kwargs={'article_id': self.root_article.id, 'revision_id': previous_revision}
            ),
        )

        new_revision = models.Article.objects.get(
            id=self.root_article.id
        ).current_revision.id

        self.assertContains(
            response,
            'Previewing merge between:'
        )
        self.assertContains(
            response,
            '#{rev_id}'.format(rev_id=previous_revision)
        )
        self.assertContains(
            response,
            '#{rev_id}'.format(rev_id=new_revision)
        )