def test_read_post(self): test_title = 'Testing the title.' test_body = 'This is the body of the test microblog post.' test_cat = '' test_auth = 1 microblog.write_post(test_title, test_body, test_cat, test_auth) expected_post = microblog.Post( test_title, test_body, [], test_auth) result_post = microblog.read_post(1) self.assertEqual(expected_post.title, result_post.title) self.assertEqual(expected_post.body, result_post.body)
def test_read_post(self): self.setup_posts() for index in range(1, 5): self.assertTrue(read_post(index)) with self.assertRaises(KeyError): read_post(6)
def test_read_post(self): self.assertTrue(microblog.read_post(1))
def testFirst(self): write_post(u"Newer Post", u""" The text containing the newer post in the blog.""", self.auth_id, self.auth_name) self.assertIsInstance(read_post(1), Post)
def testEmpty(self): with self.assertRaises(IndexError): read_post(1)
def test_read_post(self): """Add several posts and attempt to fetch one by its id.""" post = microblog.read_post(2) self.assertIn(post.title, self.posts) self.assertEqual(post.body, self.posts[post.title])
def test_readPost_bad_id(self): with self.assertRaises(KeyError): read_post(9) read_post('POEM')
def test_readPost(self): self.POETRY() self.assertEqual(Post.query.all()[3], read_post(4))