def init_db(): """ Creates tables by SQLAlchemy models """ settings = get_normalized_settings() engine = get_db_engine(settings) Base.metadata.create_all(bind=engine)
def test(): """ Runs tests with nose """ settings = get_normalized_settings() engine = get_db_engine(settings) Base.metadata.create_all(bind=engine) fab_run("nosetests -vs")
def init_db(): """ Creates tables by SQLAlchemy models """ settings = get_normalized_settings() engine = get_db_engine(settings) Base.metadata.create_all(bind=engine) db = get_db_session(settings) factory = ServerInstancesFactory(db) factory.gen_servers()
def init_db(dump=None): """Initialize ecomap_db database. If you set the dump configuration like fab init_db:from_dump, you will receive the data from dump. Otherwise you will create a new db without data. """ fab_run('sudo -u postgres psql -f init_ecomap_db.sql;' 'export PYTHONPATH=":/ecomap"') if dump == 'from_dump': path_to_dal = '/ecomap/api/dal' fab_run( 'sudo -u postgres psql ecomap_db < %s/dumps/ecomap_db_dump.sql;' % path_to_dal) else: Base.metadata.create_all(get_db_engine(settings)) fab_run('sudo -u postgres psql -f /ecomap/api/dal/view.sql;')
import random from factories.problem import (ProblemActivityFactory, ProblemFactory, ProblemTypeFactory) from factories.comment import CommentFactory from factories.user import (PermissionFactory, UserFactory, UserRoleFactory, RolePermissionFactory) import api.v1_0.models as md import factories.common as cm from api.utils.db import get_db_engine from api import settings from api.v1_0.handlers.admin import HANDLERS # first of all we need to configure the session cm.Session.configure(bind=get_db_engine(settings)) # Give role_user permissions: # * UserHandler GET, PUT, DELETE OWN # * ProblemsHandler POST # * ProblemHandler PUT, DELETE OWN # * ProblemVoteHandler POST # * ProblemCommentsHandler POST # * PhotoHandler PUT, DELETE OWN # * PermissionHandler GET NONE, POST NONE # *RoleHandler GET NONE, POST NONE user_perms = dict() user_perms['UserHandler'] = [('GET', 'OWN'), ('PUT', 'OWN'), ('DELETE', 'OWN')] user_perms['ProblemsHandler'] = \ user_perms['VoteHandler'] = [ ('POST', 'ANY')