def setup(): """Setup function for tests.""" # global variable shouldn't be used but is quite useful here # pylint: disable=W0603 global TEMP_DIR TEMP_DIR = mkdtemp() if not os.path.exists(FAKE_DIR): os.mkdir(FAKE_DIR) Git(os.path.join(FAKE_DIR, 'documents.git')).init() app = Flask( __name__, static_folder=os.path.join(PATH, 'static'), template_folder=os.path.join(PATH, 'templates')) app.config.from_object(config) app.db = SQLAlchemy(app) nuts = application.Koztumize(app) application.app = app application.nuts = nuts app.config['MODELS'] = os.path.join(TEMP_DIR, 'models') git = Git(app.config['MODELS']) git.init() git.remote('add', '-t', 'models', 'origin', app.config['GIT_REMOTE']) git.pull() git.checkout('models') execute_sql(app, 'db.sql') import koztumize.routes import koztumize.tests.document
def setup(): """Set up the git repository for the all the tests""" # global variable shouldn't be used but is quite useful here # pylint: disable=W0603 global TEMP_DIR TEMP_DIR = mkdtemp() koztumize.app.config.from_pyfile( os.environ.get('KOZTUMIZE_CONFIG', 'test/config_test.py')) koztumize.db_model.init(koztumize.app) Git.push = lambda *args, **kwargs: None for repo in ('archive', 'model'): koztumize.app.config[repo.upper()] = os.path.join(TEMP_DIR, repo) git = Git(koztumize.app.config[repo.upper()]) git.init() git.remote( 'add', '-t', repo, 'origin', koztumize.app.config['GIT_REMOTE']) git.pull() git.checkout(repo)