class DataBaseIntegrationTests: def setUp(self): if os.path.exists('./db/data.db'): # os.system('rm ../db/data.db') os.remove('./db/data.db') create_database('./db/data.db') def test_post_model_create(self): self.post_model = PostModel( 1, 'www.test_perfil.com', 'www.test_photo.com', '@Test', 1, 10, [ { "login": "******", "comment": "comment1" }, { "login": "******", "comment": "comment2" } ] ) self.assertIsNone(self.post_model.find_post(50)) self.assertIsNotNone(self.post_model.find_post(1)) def tearDown(self): # os.system('rm ./db/data.db') os.remove('./db/data.db')
def get(self, post_id): post_obejct = PostModel.find_post(post_id) if post_obejct: post = [p.json() for p in post_obejct] response = jsonify({'post': post}) response.headers.add('Access-Control-Allow-Origin', '*') return response else: return {'message': 'No post found!'}, 404