def test_delete_no_thread(self): '''存在しないthread削除 ''' self.load_fixtures() thread = Thread() with self.assertRaises(Exception) as e: thread.delete(100) self.assertEqual('thread not found', str(e.exception))
def test_delete(self): '''thread削除 ''' self.load_fixtures() thread = Thread() thread.delete(1) actual = thread.get(1) self.assertEqual(None, actual)
def delete(thread_id): '''threadを削除 同時に,thread_idに紐づくcommentテーブルも削除する Args: thread_id: スレッドID Returns: 200: 正常削除 400: threadが存在しない 500: サーバエラー ''' try: Thread.delete(thread_id) return make_response('', 200) except Exception as e: if str(e) == 'thread not found': return make_response('', 400) return make_response('', 500)