def test_delete_post(self): # create the author author = User.objects.create_user('testuser', '*****@*****.**', 'password') author.save() # create a site site = Site() site.name = 'example.com' site.domain = 'example.com' site.save() # create post post = Post() post.title = 'Delete Test' post.content = 'Test post for delete test' post.author = author post.pub_date = timezone.now() post.slug = 'delete-test' post.site = site post.save() # check the post is saved all_post = Post.objects.all() self.assertEquals(len(all_post), 1) only_post = all_post[0] # login self.client.login(username='******', password='******') # delete post response = self.client.post('/admin/blogengine/post/1/delete/', dict(post='yes'), follow=True) self.assertEquals(response.status_code, 200) self.assertTrue('deleted successfully' in response.content) all_post = Post.objects.all() self.assertNotEquals(len(all_post), 1)