Browse Source

Extra tests for posting

Rafał Pitoń 10 years ago
parent
commit
79b395ec77

+ 24 - 0
misago/threads/tests/test_editpost_view.py

@@ -415,3 +415,27 @@ class EditPostTests(AuthenticatedUserTestCase):
 
         thread = Thread.objects.get(id=self.thread.id)
         self.assertIsNone(thread.label_id)
+
+    def test_empty_form(self):
+        """empty form has no errors"""
+        acls = {
+            'can_edit_posts': 1,
+            'can_edit_threads': 1,
+            'can_change_threads_labels': 1
+        }
+
+        self.override_forum_acl(acls)
+        response = self.client.post(self.link, data={
+            'title': '',
+            'post': '',
+            'preview': True},
+        **self.ajax_header)
+        self.assertEqual(response.status_code, 200)
+
+        self.override_forum_acl(acls)
+        response = self.client.post(self.link, data={
+            'title': '',
+            'post': '',
+            'submit': True},
+        **self.ajax_header)
+        self.assertEqual(response.status_code, 200)

+ 18 - 0
misago/threads/tests/test_replythread_view.py

@@ -223,3 +223,21 @@ class ReplyThreadTests(AuthenticatedUserTestCase):
         **self.ajax_header)
         self.assertEqual(response.status_code, 200)
         self.assertFalse(Thread.objects.get(id=self.thread.id).is_pinned)
+
+    def test_empty_form(self):
+        """empty form has no errors"""
+        self.allow_reply_thread()
+        response = self.client.post(self.link, data={
+            'title': '',
+            'post': '',
+            'preview': True},
+        **self.ajax_header)
+        self.assertEqual(response.status_code, 200)
+
+        self.allow_reply_thread()
+        response = self.client.post(self.link, data={
+            'title': '',
+            'post': '',
+            'submit': True},
+        **self.ajax_header)
+        self.assertEqual(response.status_code, 200)

+ 31 - 0
misago/threads/tests/test_startthread_view.py

@@ -1,3 +1,6 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
 import json
 
 from django.conf import settings
@@ -218,3 +221,31 @@ class StartThreadTests(AuthenticatedUserTestCase):
 
         last_thread = self.user.thread_set.all()[:1][0]
         self.assertEqual(last_thread.label_id, label.id)
+
+    def test_unicode(self):
+        """unicode chars can be posted"""
+        self.allow_start_thread()
+        response = self.client.post(self.link, data={
+            'title': 'Brzęczyżczykiewicz',
+            'post': 'Chrzążczyżewoszyce, powiat Łękółody.',
+            'preview': True},
+        **self.ajax_header)
+        self.assertEqual(response.status_code, 200)
+
+    def test_empty_form(self):
+        """empty form has no errors"""
+        self.allow_start_thread()
+        response = self.client.post(self.link, data={
+            'title': '',
+            'post': '',
+            'preview': True},
+        **self.ajax_header)
+        self.assertEqual(response.status_code, 200)
+
+        self.allow_start_thread()
+        response = self.client.post(self.link, data={
+            'title': '',
+            'post': '',
+            'submit': True},
+        **self.ajax_header)
+        self.assertEqual(response.status_code, 200)