Example #1
0
 def test_create_trans_post(self):
     form = CreatePostForm(self.user, {
         'type': Post.TYPE_TRANSLATE,
         'title': 'okok',
         'text': 'ok',
         'addition': 'http://welinux.ru',
     })
     self.assertTrue(form.is_valid(), msg='trans post validation failed')
     post = form.save()
     self.assertIsNotNone(post.id, msg='trans post saving not work')
     self.assertEqual(post.addition, 'http://welinux.ru', msg='trans post data broken')
Example #2
0
 def text_draft_to_post(self):
     draft = Draft.objects.create(
         title='okok',
         author=self.user,
         type=Post.TYPE_POST,
     )
     form = CreatePostForm(self.user, draft.to_form_data())
     self.assertTrue(form.is_valid(), msg='convert draft to post validation failed')
     post = form.save()
     draft.delete()
     self.assertIsNotNone(post.id, msg='converted post saving failed')
     self.assertEqual(post.title, 'okok', msg='post from draft data broken')
Example #3
0
 def text_draft_to_post(self):
     draft = Draft.objects.create(
         title='okok',
         author=self.user,
         type=Post.TYPE_POST,
     )
     form = CreatePostForm(self.user, draft.to_form_data())
     self.assertTrue(form.is_valid(),
                     msg='convert draft to post validation failed')
     post = form.save()
     draft.delete()
     self.assertIsNotNone(post.id, msg='converted post saving failed')
     self.assertEqual(post.title, 'okok', msg='post from draft data broken')
Example #4
0
 def test_create_simple_post(self):
     form = CreatePostForm(self.user, {
         'type': Post.TYPE_POST,
         'title': 'OKOK!',
         'text': 'good',
         'raw_tags': 'op, ko, lot',
     })
     self.assertTrue(form.is_valid(), msg='simple post without blog validation failed')
     form.is_valid()
     post = form.save()
     self.assertIsNotNone(post.id, msg='simple post saving not work')
     self.assertEqual('OKOK!', post.title, msg='post data broken')
     self.assertEqual(Post.TYPE_POST, post.type, msg='post data broken')
Example #5
0
 def test_create_trans_post(self):
     form = CreatePostForm(
         self.user, {
             'type': Post.TYPE_TRANSLATE,
             'title': 'okok',
             'text': 'ok',
             'addition': 'http://welinux.ru',
         })
     self.assertTrue(form.is_valid(), msg='trans post validation failed')
     post = form.save()
     self.assertIsNotNone(post.id, msg='trans post saving not work')
     self.assertEqual(post.addition,
                      'http://welinux.ru',
                      msg='trans post data broken')
Example #6
0
 def test_create_post_with_blog(self):
     BlogType.objects.create(name=settings.DEFAULT_BLOG_TYPE)
     blog = Blog.objects.create(name='okok', owner=self.user)
     UserInBlog.objects.create(blog=blog, user=self.user)
     form = CreatePostForm(self.user, {
         'type': Post.TYPE_POST,
         'title': 'okok',
         'text': 'okokok',
         'blog': blog.id,
     })
     self.assertTrue(form.is_valid(), msg='post with blog validation failed')
     post = form.save()
     self.assertIsNotNone(post.id, msg='post with blog saving not work')
     self.assertEqual(post.blog, blog, msg='blog not assigned')
Example #7
0
 def test_create_post_with_blog(self):
     BlogType.objects.create(name=settings.DEFAULT_BLOG_TYPE)
     blog = Blog.objects.create(name='okok', owner=self.user)
     UserInBlog.objects.create(blog=blog, user=self.user)
     form = CreatePostForm(
         self.user, {
             'type': Post.TYPE_POST,
             'title': 'okok',
             'text': 'okokok',
             'blog': blog.id,
         })
     self.assertTrue(form.is_valid(),
                     msg='post with blog validation failed')
     post = form.save()
     self.assertIsNotNone(post.id, msg='post with blog saving not work')
     self.assertEqual(post.blog, blog, msg='blog not assigned')
Example #8
0
 def test_create_simple_post(self):
     form = CreatePostForm(
         self.user, {
             'type': Post.TYPE_POST,
             'title': 'OKOK!',
             'text': 'good',
             'raw_tags': 'op, ko, lot',
         })
     self.assertTrue(form.is_valid(),
                     msg='simple post without blog validation failed')
     form.is_valid()
     post = form.save()
     self.assertIsNotNone(post.id, msg='simple post saving not work')
     self.assertEqual('OKOK!', post.title, msg='post data broken')
     self.assertEqual(Post.TYPE_POST, post.type, msg='post data broken')