I'm doing a test of api, that I pass a json it validates me if everything went ok:
My base class:
# -*- coding: utf-8 -*-
# base.py
import os
import unittest
from app import initialize
from mock import mock
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from app import database
os.environ = {
my_variavels:
}
test_app = Flask(__name__)
test_app.config.from_object('app.config.TestingConfig')
database.AppRepository.db = SQLAlchemy(test_app)
class TestCase(unittest.TestCase):
mock = mock
user = initialize.web_app.test_client()
I believe that in this base file, it should have the functions teardown, Setup etc ..
json_gardener = {"id": "1",
"name": "Jamme"}
And I have the following function that does the post in this case:
def test_post_gardener(self):
response = self.user.post('/gardeners', headers={'VALIDATION': 'XXXX'}, data=self.json_gardener)
self.assertEqual(response.status_code, 201)
Until then everything works fine, but when I run the second time it obviously goes that the id already exists in the database and will give error.
My question to the following is there a way to upload a database to test and when it finishes running it dismount?