示例#1
0
 def test_listing(self):
     expected = ("My Title","My Text")
     with self.app.test_request_context('/'):
         self.app.preprocess_request()
         flaskr.write_entry(*expected)
     rv = self.client.get('/')
     for value in expected:
         assert value in rv.data
示例#2
0
 def test_get_all_entries(self):
     expected = ("My Title","My Text")
     with self.app.test_request_context('/'):
         self.app.preprocess_request()
         flaskr.write_entry(*expected)
         entries = flaskr.get_all_entries()
         self.assertEquals(len(entries), 1)
         for entry in entries:
             self.assertEquals(expected[0], entry['title'])
             self.assertEquals(expected[1], entry['text'])
示例#3
0
 def test_write_entry(self):
     expected = ("My Title","My Text")
     with self.app.test_request_context('/'):
         self.app.preprocess_request()
         flaskr.write_entry(*expected)
         con = flaskr.connect_db()
         cur = con.execute("select * from entries;")
         rows = cur.fetchall()
     self.assertEquals(len(rows), 1)
     for val in expected:
         self.assertTrue(val in rows[0])
 def test_write_entry(self):
     """
     Test the write_entry() method of flaskr.
     """
     expected = ("My Title", "My Text")
     with self.app.test_request_context('/'):
         self.app.preprocess_request()
         # Insert our test data into the test database.
         flaskr.write_entry(*expected)
         con = flaskr.connect_db()
         # Check for presence of test data.
         cur = con.execute("select * from entries;")
         rows = cur.fetchall()
     self.assertEquals(len(rows), 1)
     for val in expected:
         # Actually check the values against expected.
         self.assertTrue(val in rows[0])