Пример #1
0
def setup(self):
    """
    Setup an instance of the Flask app with suitable temporary directories and mocks.
    """
    self.config_dir = mkdtemp()
    self.config_file = join(self.config_dir, "cheddar.conf")
    self.local_cache_dir = mkdtemp()
    self.remote_cache_dir = mkdtemp()

    with open(self.config_file, "w") as file_:
        file_.write('LOCAL_CACHE_DIR = "{}"\n'.format(self.local_cache_dir))
        file_.write('REMOTE_CACHE_DIR = "{}"\n'.format(self.remote_cache_dir))

    self.previous_config_file = environ.get("CHEDDAR_SETTINGS")
    environ["CHEDDAR_SETTINGS"] = self.config_file

    with patch('cheddar.configure.Redis', MockRedis):
        self.app = create_app(testing=True)
Пример #2
0
def main():
    parser = ArgumentParser(formatter_class=ArgumentDefaultsHelpFormatter)
    parser.add_argument('-a',
                        dest='all_interfaces',
                        action='store_true',
                        default=False,
                        help='Listen on all interfaces')
    parser.add_argument('-p',
                        dest='port',
                        type=int,
                        default=5000,
                        help='Listen port')
    args, extra = parser.parse_known_args()

    app = create_app(debug=True)

    if args.all_interfaces:
        app.run(host='0.0.0.0',
                port=args.port)
    else:
        app.run(port=args.port)
Пример #3
0
    def setup(self):
        self.config_dir = mkdtemp()
        self.config_file = join(self.config_dir, "cheddar.conf")
        self.local_cache_dir = mkdtemp()
        self.remote_cache_dir = mkdtemp()
        self.username = "******"
        self.password = "******"

        with open(self.config_file, "w") as file_:
            file_.write('LOCAL_CACHE_DIR = "{}"\n'.format(self.local_cache_dir))
            file_.write('REMOTE_CACHE_DIR = "{}"\n'.format(self.remote_cache_dir))

        self.previous_config_file = environ.get("CHEDDAR_SETTINGS")
        environ["CHEDDAR_SETTINGS"] = self.config_file

        with patch('cheddar.configure.Redis', MockRedis):
            self.app = create_app(testing=True)

        self.client = self.app.test_client()
        self.use_json = dict(accept="application/json; charset=UTF-8")
        self.use_auth = dict(authorization="Basic {}".format(b64encode("{}:{}".format(self.username,
                                                                                      self.password))))
        self.app.redis.set("cheddar.user.{}".format(self.username), self.password)
Пример #4
0
"""
Production WSGI hook.

Creates and configures a new application.

By default uwsgi will use a module's 'application' value.
"""
from cheddar.app import create_app


application = create_app()