Beispiel #1
0
 def test_save_success(self):
     """投稿データがデータベースに正常に保存されること
     """
     save_data = self.getOne()
     with test_database(test_db, (Greeting,)):
         save_data(u'tokibito', u'テスト', datetime(2013, 12, 2, 10, 0))
         greeting_list = list(Greeting.select())
         self.assertEqual(len(greeting_list), 1)
         self.assertEqual(greeting_list[0].name, u'tokibito')
         self.assertEqual(greeting_list[0].comment, u'テスト')
         self.assertEqual(greeting_list[0].create_at, datetime(2013, 12, 2, 10, 0))
Beispiel #2
0
 def test_success(self):
     bottle.request = bottle.LocalRequest(
         {'wsgi.input': StringIO('name=tokibito&comment=テスト'),
          'CONTENT_LENGTH': 31})
     post = self.getOne()
     try:
         post()
     except bottle.HTTPResponse as res:
         self.assertEqual(res.headers['Location'], 'http://127.0.0.1/')
     greeting_list = list(Greeting.select())
     self.assertEqual(len(greeting_list), 1)
     self.assertEqual(greeting_list[0].name, 'tokibito')
     self.assertEqual(greeting_list[0].comment, u'テスト')