From 1dc7353c392dae793fe2854c148c898f138e8ece Mon Sep 17 00:00:00 2001 From: Benjamin Bach Date: Tue, 27 Dec 2016 23:01:24 +0100 Subject: [PATCH] Add test of merge preview --- .gitignore | 3 +++ wiki/tests/test_views.py | 49 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/.gitignore b/.gitignore index 98650662..d1d4700c 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,9 @@ wiki/attachments #PyCharm .idea +# Test artifacts +cache +wiki/images #Docs docs/_build diff --git a/wiki/tests/test_views.py b/wiki/tests/test_views.py index 1a80c2a4..3b69cc7f 100644 --- a/wiki/tests/test_views.py +++ b/wiki/tests/test_views.py @@ -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) + ) -- 2.45.2