class PostVisibilityTests(TestCase): def setUp(self): self.fake_user = User(username='******', password='******') self.fake_user.save() self.fake_post = Post(title='Fake Post', author=self.fake_user, content='This is a fake post used for testing') def test_post_publish_method_sets_is_published_to_True(self): self.fake_post.publish() self.assertTrue(self.fake_post.is_published) def test_post_unpublish_method_sets_is_publised_to_False(self): self.fake_post.unpublish() self.assertFalse(self.fake_post.is_published) def test_post_delete_method_sets_is_deleted_to_True(self): self.fake_post.delete() self.assertTrue(self.fake_post.is_deleted)
def test_post_publish(self): post = Post(author=self.me, title="Hi", created_date=timezone.now()) post.publish() self.assertLess(post.published_date, timezone.now())