Пример #1
0
    def test_drop_database(self, connection_method):
        connection_method.return_value = Mock(__enter__=Mock, __exit__=Mock())

        with patch.object(rethink, 'db_drop', return_value=Mock()) as \
                db_drop_method:

            drop_database()

            db_drop_method.assert_called_once_with(DEFAULT_DB_NAME)
Пример #2
0
    def test_drop_database(self, connection_method):
        connection_method.return_value = Mock(__enter__=Mock, __exit__=Mock())

        with patch.object(rethink, 'db_drop', return_value=Mock()) as \
                db_drop_method:

            drop_database()

            db_drop_method.assert_called_once()
            db_drop_method.run.assert_called_once()
            db_drop_method.assert_called_with(DEFAULT_DB_NAME)
Пример #3
0
def main(arguments=None):  # pragma: no cover
    parser = argparse.ArgumentParser(description='Run the PyWebHooks app')
    parser.add_argument('--initdb', dest='initdb', action='store_true')
    args = parser.parse_args(arguments)

    if args.initdb:
        print('Dropping database...')
        try:
            drop_database()
        except Exception as ex:
            print(str(ex))
        print('Creating database...')
        create_database()
        print('Adding admin account')
        print(create_admin_account())
        print('Complete')
    else:
        app.run(debug=True, port=8081, host='0.0.0.0')
Пример #4
0
    CELERY.conf.update(flask_app.config)

    return flask_app


CELERY = Celery(__name__, broker=CELERY_BROKER_URL)
app = create_wsgi_app()


@app.before_request
def before_request():
    if request.headers['content-type'].lower().find('application/json'):
        return 'Unsupported Media Type', 415


if __name__ == '__main__':  # pragma: no cover
    parser = argparse.ArgumentParser(description='Run the PyWebHooks app')
    parser.add_argument('--initdb', dest='initdb', action='store_true')
    args = parser.parse_args()

    if args.initdb:
        print('Dropping database...')
        drop_database()
        print('Creating database...')
        create_database()
        print('Adding admin account')
        print(create_admin_account())
        print('Complete')
    else:
        app.run(debug=True, port=8081)
Пример #5
0
def initdb():
    drop_database()
    create_database()
    return create_admin_account()
Пример #6
0
 def test_drop_database_throws_rql_runtime_error(self, _):
     with self.assertRaises(RqlRuntimeError) as cm:
         drop_database()
         self.assertEqual(cm.exception, RqlRuntimeError(None, None, None))
Пример #7
0
 def test_drop_database_throws_rql_driver_error(self, _):
     with self.assertRaises(RqlDriverError) as cm:
         drop_database()
         self.assertEqual(cm.exception, RqlDriverError(None))