예제 #1
0
def initdb():
    """Init/reset database."""

    db.drop_all()
    db.create_all()

    from ad2web.notifications.models import NotificationMessage
    from ad2web.notifications.constants import DEFAULT_EVENT_MESSAGES

    for event, message in DEFAULT_EVENT_MESSAGES.iteritems():
        db.session.add(NotificationMessage(id=event, text=message))

    db.session.commit()
예제 #2
0
def initdb():
    """Init/reset database."""

    db.drop_all()
    db.create_all()

    # Initialize alembic revision
    from alembic.config import Config
    from alembic import command
    alembic_cfg = Config('alembic.ini')
    command.stamp(alembic_cfg, "head")

    from ad2web.notifications.models import NotificationMessage
    from ad2web.notifications.constants import DEFAULT_EVENT_MESSAGES

    for event, message in DEFAULT_EVENT_MESSAGES.iteritems():
        db.session.add(NotificationMessage(id=event, text=message))

    db.session.commit()
예제 #3
0
def initdb():
    """Init/reset database."""

    db.drop_all()
    db.create_all()

    # Initialize alembic revision
    from alembic.config import Config
    from alembic import command
    alembic_cfg = Config('alembic.ini')
    command.stamp(alembic_cfg, "head")

    from ad2web.notifications.models import NotificationMessage
    from ad2web.notifications.constants import DEFAULT_EVENT_MESSAGES

    for event, message in DEFAULT_EVENT_MESSAGES.iteritems():
        db.session.add(NotificationMessage(id=event, text=message))

    db.session.commit()
예제 #4
0
    def run(self):
        """Init/reset database."""

        try:
            db.drop_all()
            db.create_all()

            # Initialize alembic revision
            from alembic.config import Config
            from alembic import command
            alembic_cfg = Config('alembic.ini')
            command.stamp(alembic_cfg, "head")

            from ad2web.notifications.models import NotificationMessage
            from ad2web.notifications.constants import DEFAULT_EVENT_MESSAGES

            for event, message in DEFAULT_EVENT_MESSAGES.iteritems():
                db.session.add(NotificationMessage(id=event, text=message))

            db.session.commit()
        except Exception, err:
            print("Database initialization failed: {0}".format(err))
예제 #5
0
    def run(self):
        """Init/reset database."""

        try:
            db.drop_all()
            db.create_all()

            # Initialize alembic revision
            from alembic.config import Config
            from alembic import command
            alembic_cfg = Config('alembic.ini')
            command.stamp(alembic_cfg, "head")

            from ad2web.notifications.models import NotificationMessage
            from ad2web.notifications.constants import DEFAULT_EVENT_MESSAGES

            for event, message in DEFAULT_EVENT_MESSAGES.iteritems():
                db.session.add(NotificationMessage(id=event, text=message))

            db.session.commit()
        except Exception, err:
            print("Database initialization failed: {0}".format(err))
예제 #6
0
    def setUp(self):
        """Reset all tables before testing."""

        db.create_all()
        self.init_data()
    def setUp(self):
        """Reset all tables before testing."""

        db.create_all()
        self.init_data()