Ejemplo n.º 1
0
 def test_read_posts(self):
     """Read the number of posts we have and verify that they contain
     the expected content.
     """
     posts = microblog.read_posts()
     self.assertEqual(len(posts), 2)
     for post in posts:
         self.assertIn(post.title, self.posts)
         self.assertEqual(post.body, self.posts[post.title])
Ejemplo n.º 2
0
 def test_read_posts(self):
     self.setup_posts()
     post_list = read_posts()
     TITLE.reverse()
     BODY_TEXT.reverse()
     for index in range(4):
         self.assertEquals(post_list[index].title, TITLE[index])
         self.assertEquals(post_list[index].body, BODY_TEXT[index])
         self.assertEquals(post_list[index].author.username,
                           self.username)
Ejemplo n.º 3
0
 def testReadOne(self):
     expected = Post(u"New Post", u"""
         The text containing the newest post in the blog.""", self.auth_id, self.auth_name)
     write_post(u"New Post", u"""
         The text containing the newest post in the blog.""", self.auth_id, self.auth_name)
     actual = read_posts()[0]
     self.assertEqual(expected.title, actual.title)
     self.assertEqual(expected.body, actual.body)
     self.assertEqual(self.auth_id, actual.author_id)
     self.assertEqual(self.auth_name, actual.auth_name)
Ejemplo n.º 4
0
 def test_read_posts_order(self):
     """Add a new post, then verify that calling read_posts() places
     it at the top of the list of posts it returns.
     """
     microblog.write_post(self.title, self.body, self.auth_id)
     posts = microblog.read_posts()
     self.assertEqual(len(posts), 3)
     self.assertEqual(posts[0].title, self.title)
     self.assertEqual(posts[0].body, self.body)
     self.assertEqual(posts[0].auth_id, self.auth_id)
Ejemplo n.º 5
0
 def test_write_post(self):
     """Write a post and then verify that it appeared at the top of
     the microblog.
     """
     microblog.write_post(self.title, self.body, self.auth_id)
     posts = microblog.read_posts()
     self.assertEqual(len(posts), 1)
     self.assertEqual(posts[0].title, self.title)
     self.assertEqual(posts[0].body, self.body)
     self.assertEqual(posts[0].auth_id, self.auth_id)
Ejemplo n.º 6
0
    def test_read_posts(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_post1 = microblog.Post(
            test_title, test_body, [], test_auth)

        test_title = 'Testing the title a second time.'
        test_body = 'This is the body of the second test microblog post.'
        microblog.write_post(test_title, test_body, test_cat, test_auth)
        expected_post2 = microblog.Post(
            test_title, test_body, [], test_auth)

        results = microblog.read_posts()
        result_post1 = results[1]
        result_post2 = results[0]

        self.assertEqual(expected_post1.title, result_post1.title)
        self.assertEqual(expected_post1.body, result_post1.body)

        self.assertEqual(expected_post2.title, result_post2.title)
        self.assertEqual(expected_post2.body, result_post2.body)
Ejemplo n.º 7
0
 def test_read_posts(self):
     self.assertEqual(len(microblog.read_posts()), 3)
Ejemplo n.º 8
0
 def testEmpty(self):
     self.assertEqual(len(read_posts()), 0)
Ejemplo n.º 9
0
 def test_readPosts_empty(self):
     self.assertEqual(read_posts().__repr__(), '[]')
Ejemplo n.º 10
0
 def test_readPosts(self):
     self.POETRY()
     reverse_chron = "[POST: u'M', POST: u'E', POST: u'O', POST: u'P']"
     self.assertEqual(read_posts().__repr__(), reverse_chron)
     self.assertNotEqual(Post.query.all().__repr__(), reverse_chron)