Commit 159025bc by benjaoming

Merge pull request #139 from hynekcer/master

Fixed broken Preview (displaying the old article content)
parents c3bbc377 634c3c0a
...@@ -119,8 +119,7 @@ class EditForm(forms.Form, SpamProtectionMixin): ...@@ -119,8 +119,7 @@ class EditForm(forms.Form, SpamProtectionMixin):
# is reset to match the actual current revision. # is reset to match the actual current revision.
data = None data = None
if len(args) > 0: if len(args) > 0:
args = list(args) data = args[0]
data = args.pop(0)
if not data: if not data:
data = kwargs.get('data', None) data = kwargs.get('data', None)
if data: if data:
......
""" from django.contrib.auth.models import User
This file demonstrates writing tests using the unittest module. These will pass from django.core.urlresolvers import reverse
when you run "manage.py test". from django.test import TestCase
from django.test.client import Client
Replace this with more appropriate tests for your application. class WebClientTest(TestCase):
""" def test_preview_save(self):
"""Test the basic operations (create, preview and save the article) by web client."""
c = Client()
User.objects.create_superuser('admin', 'nobody@example.com', 'secret')
c.login(username='admin', password='secret')
response = c.get(reverse('wiki:root')) # url '/'
self.assertRedirects(response, reverse('wiki:root_create')) # url '/create-root/'
from django.test import TestCase # test create the root article
response = c.post(reverse('wiki:root_create'),
{'content': 'test heading h1\n====\n', 'save_changes': 'Create root...', 'title': 'wiki test'})
self.assertRedirects(response, reverse('wiki:root'))
response = c.get(reverse('wiki:root'))
self.assertContains(response, 'test heading h1</h1>')
# test preview
form_data = {
'content': 'The modified text',
'current_revision': '1',
'preview': '1',
'save': '1',
'summary': 'any summary',
'title': 'wiki test'}
response = c.post(reverse('wiki:preview', kwargs={'path': ''}), form_data) # url: '/_preview/'
self.assertContains(response, 'The modified text') # preview failed
class SimpleTest(TestCase): # test save
def test_basic_addition(self): response = c.post(reverse('wiki:edit', kwargs={'path': ''}), form_data)
""" message = c.cookies['messages'].value if 'messages' in c.cookies else None
Tests that 1 + 1 always equals 2. self.assertRedirects(response, reverse('wiki:root'))
""" response = c.get(reverse('wiki:root'))
self.assertEqual(1 + 1, 2) self.assertContains(response, 'The modified text')
# test messages
self.assertTrue('succesfully added' in message)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment