コード例 #1
0
ファイル: tests.py プロジェクト: markcharyk/flask-microblog
 def testOne(self):
     with app.test_request_context():
         write_post(u"Post Title", u"A generic blog post", self.auth_id, self.auth_name)
         expected = ('Post Title', 'A generic blog post', 'testauthor')
         response = self.client.get('/').data
         for elem in expected:
             assert elem in response
コード例 #2
0
ファイル: tests.py プロジェクト: markcharyk/flask-microblog
 def testOne(self):
     with app.test_request_context():
         write_post(u"Single Post", u"Bloggity blog post, just one this time", self.auth_id, self.auth_name)
         expected = ('Single Post', 'Bloggity blog post, just one this time', 'testauthor')
         response = self.client.get('/post/1').data
         for elem in expected:
             assert elem in response
コード例 #3
0
ファイル: tests.py プロジェクト: risingmoon/flask-microblog
 def test_long_title(self):
     author = Author.query.first()
     with self.assertRaises(DataError):
         write_post(
             """THOU HAST WRITTEN A RIDICULOUS TITLE THAT
             SHALL EXCEED THE MAXIMIUM THRESHOLD ALLOWED""",
             "I LOVE UNIT-TESTING IN PYTHON!!!!", author)
コード例 #4
0
ファイル: tests.py プロジェクト: markcharyk/flask-microblog
 def testWriteOne(self):
     expected = Post(u"First Post", u"""
         The text containing the first post in the blog.""", self.auth_id, self.auth_name)
     write_post(u"First Post", u"""
         The text containing the first post in the blog.""", self.auth_id, self.auth_name)
     actual = Post.query.filter_by(title=u'First Post').first()
     self.assertEqual(expected.title, actual.title)
     self.assertEqual(expected.body, actual.body)
     self.assertEqual(expected.auth_name, actual.auth_name)
コード例 #5
0
ファイル: tests.py プロジェクト: tsnaomi/flask_microblog
 def test_writePost(self):
     self.LOGIN(self.author, self.password)
     session['current_user'] = self.author
     write_post(self.spring, self.imaginations)
     post = Post.query.all()[0]
     self.assertEqual(len(Post.query.all()), 1)
     self.assertEqual(post.title, self.spring)
     self.assertEqual(post.body, self.imaginations)
     self.assertTrue(post.pub_date)
コード例 #6
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)
コード例 #7
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)
コード例 #8
0
ファイル: tests.py プロジェクト: markcharyk/flask-microblog
 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)
コード例 #9
0
ファイル: tests.py プロジェクト: jbrengman/flask-microblog
 def test_write_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.Post.query.filter_by(title=test_title).first()
     self.assertEqual(expected_post.title, result_post.title)
     self.assertEqual(expected_post.body, expected_post.body)
コード例 #10
0
ファイル: tests.py プロジェクト: jbrengman/flask-microblog
 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)
コード例 #11
0
ファイル: tests.py プロジェクト: risingmoon/flask-microblog
    def test_write_post(self):
        author = Author.query.first()
        write_post(TITLE[0], BODY_TEXT[0], author)
        self.assertEquals(len(Post.query.all()), 1)
        post = Post.query.all()[0]

        #Test Attributes
        self.assertEquals(post.title, TITLE[0])
        self.assertEquals(post.body, BODY_TEXT[0])
        self.assertTrue(post.pub_date)
        self.assertEqual(post.author.username, self.username)
コード例 #12
0
 def setUp(self):
     microblog.db.create_all()
     microblog.add_user(
         'admin', 'password', '*****@*****.**', confirm=False)
     self.user_id = \
         microblog.User.query.filter_by(username='******').first().id
     self.posts = {
         "Blog 1": "A Blog Body",
         "Blog 2": "Another Blog Body",
         "Blog 3": "A Third Blog Body",
     }
     for title, body in sorted(self.posts.items(), key=lambda x: x[0]):
         microblog.write_post(title, body, self.user_id)
コード例 #13
0
    def setUp(self):
        microblog.db.create_all()
        microblog.add_user(
            'admin', 'password', '*****@*****.**', confirm=False)
        self.auth_id = \
            microblog.User.query.filter_by(username='******').first().id
        self.posts = {
            'A Blog Title': 'A Blog Body',
            'Eye-Catching Headline': 'Earth-Shattering Content',
        }
        for key, val in self.posts.items():
            microblog.write_post(key, val, self.auth_id)

        self.title = "Another Blog Title"
        self.body = "Another Blog Body"
コード例 #14
0
ファイル: tests.py プロジェクト: sniboboof/flask-microblog
 def testCategoryView(self):
     microblog.register_author('jack', 'markley')
     testpost = microblog.write_post("test title", "test body", 1)
     testcategory = microblog.new_category('testcategory')
     microblog.link_post_category(testpost, testcategory)
     rv = self.app.get('category/1')
     assert 'test title' in rv.data
コード例 #15
0
ファイル: tests.py プロジェクト: sniboboof/flask-microblog
    def testPostView(self):
        microblog.register_author('jack', 'markley')
        microblog.register_author('jeff', 'haskins')
        rv = self.app.get('/post/1')
        assert "That post hasn't been written yet!" in rv.data

        microblog.write_post("test title", "test body", 1)
        microblog.write_post("test title2", "test body2", 2)
        microblog.write_post("test title3", "test body3", 1)
        rv = self.app.get('/post/1')
        assert 'test title' in rv.data
        assert 'test body' in rv.data
        assert 'jack' in rv.data
        assert 'jeff' not in rv.data
        rv = self.app.get('/post/2')
        assert 'test title2' in rv.data
        assert 'test body2' in rv.data
        assert 'jeff' in rv.data
        assert 'jack' not in rv.data
        rv = self.app.get('/post/3')
        assert 'test title3' in rv.data
        assert 'test body3' in rv.data
        assert 'jack' in rv.data
        rv = self.app.get('/post/78')
        assert "That post hasn't been written yet!" in rv.data
コード例 #16
0
ファイル: tests.py プロジェクト: sniboboof/flask-microblog
    def testSingleGet(self):
        microblog.register_author('jack', 'markley')
        microblog.write_post("test title", "test body", 1)
        microblog.write_post("test title2", "test body2", 1)
        microblog.write_post("test title3", "test body3", 1)

        self.assertEqual(microblog.get_post(1).BlagPost.title, "test title")
        self.assertEqual(microblog.get_post(3).BlagPost.body, "test body3")
コード例 #17
0
ファイル: tests.py プロジェクト: markcharyk/flask-microblog
 def testMany(self):
     with app.test_request_context():
         write_post(u"Post One", u"The first blog post in a list", self.auth_id, self.auth_name)
         write_post(u"Post Two", u"The second blog post in a list", self.auth_id, self.auth_name)
         write_post(u"Post Three", u"The third blog post in a list", self.auth_id, self.auth_name)
         expected = ('Post Three', 'The third blog post in a list', 'testauthor')
         response = self.client.get('/post/3').data
         for elem in expected:
             self.assertIn(elem, response)
コード例 #18
0
ファイル: tests.py プロジェクト: sniboboof/flask-microblog
    def testBlagGet(self):
        microblog.register_author('jack', 'markley')
        microblog.write_post("test title", "test body", 1)
        microblog.write_post("test title2", "test body2", 1)
        microblog.write_post("test title3", "test body3", 1)
        a = microblog.get_posts()

        self.assertEqual(a[2].BlagPost.title, "test title")
        self.assertEqual(a[0].BlagPost.body, "test body3")
コード例 #19
0
ファイル: tests.py プロジェクト: markcharyk/flask-microblog
 def testMany(self):
     with app.test_request_context():
         write_post(u"Post Number One", u"Some text that makes up blog post number one", self.auth_id, self.auth_name)
         write_post(u"Post Number Two", u"Some text that makes up blog post number two", self.auth_id, self.auth_name)
         write_post(u"Post Number Three", u"Some text that makes up blog post number three", self.auth_id, self.auth_name)
         expected = ('Post Number One', 'Post Number Two', 'Post Number Three', 'Some text', 'testauthor')
         response = self.client.get('/').data
         for elem in expected:
             assert elem in response
コード例 #20
0
ファイル: tests.py プロジェクト: jbrengman/flask-microblog
    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)
コード例 #21
0
ファイル: tests.py プロジェクト: sniboboof/flask-microblog
    def testBlagPost(self):
        microblog.register_author('jack', 'markley')
        microblog.write_post("test title", "test body", 1)
        microblog.write_post("test title2", "test body2", 1)
        microblog.write_post("test title3", "test body3", 1)

        blags = microblog.BlagPost.query.all()

        self.assertEqual(blags[0].title, "test title")
        self.assertEqual(blags[2].body, "test body3")
コード例 #22
0
ファイル: tests.py プロジェクト: sniboboof/flask-microblog
    def testPostsView(self):
        microblog.register_author('jack', 'markley')
        microblog.register_author('jeff', 'haskins')
        microblog.register_author('ben', 'markley')
        rv = self.app.get('/')
        assert 'No posts yet' in rv.data

        microblog.write_post("test title", "test body", 1)
        microblog.write_post("test title2", "test body2", 1)
        microblog.write_post("test title3", "test body3", 2)
        rv = self.app.get('/')
        assert 'test title' in rv.data
        assert 'test title2' in rv.data
        assert 'test title3' in rv.data
        assert 'jack' in rv.data
        assert 'jeff' in rv.data
        assert 'ben' not in rv.data
コード例 #23
0
ファイル: tests.py プロジェクト: tsnaomi/flask_microblog
 def test_writePost_wordy_title(self):
     self.LOGIN(self.author, self.password)
     session['current_user'] = self.author
     with self.assertRaises(DataError):
         write_post(self.imaginations, self.spring)
コード例 #24
0
ファイル: tests.py プロジェクト: markcharyk/flask-microblog
 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)
コード例 #25
0
ファイル: tests.py プロジェクト: tsnaomi/flask_microblog
 def POETRY(self):
     for letter in 'POEM':
         session['current_user'] = self.author
         write_post(letter, self.imaginations)
コード例 #26
0
ファイル: tests.py プロジェクト: tsnaomi/flask_microblog
 def test_writePost_missing_values(self):
     self.LOGIN(self.author, self.password)
     with self.assertRaises(ValueError):
         write_post(None, None)
         write_post(self.spring, None)
         write_post(None, self.imaginations)
コード例 #27
0
ファイル: tests.py プロジェクト: risingmoon/flask-microblog
 def test_empty_title(self):
     author = Author.query.first()
     with self.assertRaises(ValueError):
         write_post(None, "I LOVE UNIT-TESTING IN PYTHON!!!!", author)
コード例 #28
0
ファイル: tests.py プロジェクト: risingmoon/flask-microblog
 def setup_posts(self):
     author = Author.query.first()
     for num in range(4):
         write_post(TITLE[num], BODY_TEXT[num], author)
コード例 #29
0
ファイル: tests.py プロジェクト: sniboboof/flask-microblog
 def testCategories(self):
     microblog.register_author('jack', 'markley')
     testpost = microblog.write_post("test title", "test body", 1)
     testcategory = microblog.new_category('testcategory')
     microblog.link_post_category(testpost, testcategory)
     assert testcategory in testpost.categories