Пример #1
0
 def test_create_draft(self):
     form = EditDraftForm(self.user, {
         'type': Post.TYPE_POST,
     })
     self.assertTrue(form.is_valid(), msg='draft validation failed')
     draft = form.save()
     self.assertIsNotNone(draft.id, msg='draft saving not work')
Пример #2
0
 def test_create_draft(self):
     form = EditDraftForm(self.user, {
         'type': Post.TYPE_POST,
     })
     self.assertTrue(form.is_valid(), msg='draft validation failed')
     draft = form.save()
     self.assertIsNotNone(draft.id, msg='draft saving not work')
Пример #3
0
 def test_edit_draft(self):
     draft = Draft.objects.create(
         title='okok',
         author=self.user,
         type=Post.TYPE_POST,
     )
     form = EditDraftForm(self.user, {
         'title': 'yee',
         'text': 'okok',
     }, instance=draft)
     form.is_valid()
     self.assertTrue(form.is_valid(), msg='edit draft validation failed')
     changed_draft = form.save()
     self.assertEqual(draft.id, changed_draft.id, msg='new draft created')
     self.assertEqual(changed_draft.title, 'yee', msg='draft edit failed')
Пример #4
0
 def test_edit_draft(self):
     draft = Draft.objects.create(
         title='okok',
         author=self.user,
         type=Post.TYPE_POST,
     )
     form = EditDraftForm(self.user, {
         'title': 'yee',
         'text': 'okok',
     },
                          instance=draft)
     form.is_valid()
     self.assertTrue(form.is_valid(), msg='edit draft validation failed')
     changed_draft = form.save()
     self.assertEqual(draft.id, changed_draft.id, msg='new draft created')
     self.assertEqual(changed_draft.title, 'yee', msg='draft edit failed')