Ejemplo n.º 1
0
def init_db():
    """
    Creates tables by SQLAlchemy models
    """
    settings = get_normalized_settings()
    engine = get_db_engine(settings)
    Base.metadata.create_all(bind=engine)
Ejemplo n.º 2
0
def init_db():
    """
    Creates tables by SQLAlchemy models
    """
    settings = get_normalized_settings()
    engine = get_db_engine(settings)
    Base.metadata.create_all(bind=engine)
Ejemplo n.º 3
0
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")
Ejemplo n.º 4
0
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()
Ejemplo n.º 5
0
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;')
Ejemplo n.º 6
0
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')