Пример #1
0
def app():
    return create_app(get_config('test'))
Пример #2
0
    def run(self):
        if app.template_service.validate():
            return 0
        else:
            return 1


def find_assets():
    """Yield paths for all static files and templates."""
    for name in ['static', 'templates']:
        directory = os.path.join(app.config['PATH'], name)
        for entry in os.scandir(directory):
            if entry.is_file():
                yield entry.path


# Select app configuration from the environment
config = get_config(os.getenv('FLASK_CONFIG', 'dev'))

# Build the app using configuration from the environment
app = create_app(config)

# Configure the command-line interface
manager = Manager(app)
manager.add_command('validate', Validate())
manager.add_command('run', Server(host='0.0.0.0', extra_files=find_assets()))

if __name__ == '__main__':
    manager.run()
Пример #3
0
 def when_empty(expect):
     with expect.raises(AssertionError):
         get_config('')
Пример #4
0
 def when_valid(expect):
     config = get_config('production')
     expect(config.ENV) == 'production'
Пример #5
0
 def test_get_valid(self):
     config = get_config('prod')
     assert issubclass(config, Config)
 def app():
     app = create_app(get_config('test'))
     app.config['GOOGLE_ANALYTICS_TID'] = 'my_tid'
     return app
Пример #7
0
 def app():
     app = create_app(get_config("test"))
     app.config["GOOGLE_ANALYTICS_TID"] = "my_tid"
     return app
Пример #8
0
 def test_get_none(self):
     with pytest.raises(AssertionError):
         get_config('')
Пример #9
0
 def when_unknown(expect):
     with expect.raises(AssertionError):
         get_config('unknown')
Пример #10
0
 def when_valid(expect):
     config = get_config('production')
     expect(config.ENV) == 'production'
Пример #11
0
 def when_empty(expect):
     with expect.raises(AssertionError):
         get_config('')
Пример #12
0
 def when_extended(expect):
     config = get_config('staging')
     expect(config.ENV) == 'staging'
Пример #13
0
    """Checks for issues in all templates."""
    def run(self):  # pylint: disable=method-hidden
        if app.template_service.validate():
            return 0
        else:
            return 1


def find_assets():
    """Yield paths for all static files and templates."""
    for name in ['static', 'templates']:
        directory = os.path.join(app.config['PATH'], name)
        for entry in os.scandir(directory):
            if entry.is_file():
                yield entry.path


# Select app configuration from the environment
config = get_config(os.getenv('FLASK_ENV', 'local'))

# Build the app using configuration from the environment
app = create_app(config)

# Configure the command-line interface
manager = Manager(app)
manager.add_command('validate', Validate())
manager.add_command('run', Server(extra_files=find_assets()))

if __name__ == '__main__':
    manager.run()
Пример #14
0
 def test_get_unknown(self):
     with pytest.raises(AssertionError):
         get_config('not_a_valid_config')
Пример #15
0
    def run(self):  # pylint: disable=method-hidden
        if app.template_service.validate():
            return 0
        else:
            return 1


def find_assets():
    """Yield paths for all static files and templates."""
    for name in ['static', 'templates']:
        directory = os.path.join(app.config['PATH'], name)
        for entry in os.scandir(directory):
            if entry.is_file():
                yield entry.path


# Select app configuration from the environment
config = get_config(os.getenv('FLASK_ENV', 'local'))

# Build the app using configuration from the environment
app = create_app(config)

# Configure the command-line interface
manager = Manager(app)
manager.add_command('validate', Validate())
manager.add_command('run', Server(extra_files=find_assets()))


if __name__ == '__main__':
    manager.run()
Пример #16
0
def unset(name):
    config = get_config('test')
    if getattr(config, name):
        return dict(condition=False, reason="")
    else:
        return dict(condition=True, reason="{} unset".format(name))
Пример #17
0
#!env/bin/python

import os
import logging

from flask_script import Manager, Server

from memegen.settings import get_config
from memegen.app import create_app


config = get_config(os.getenv('CONFIG'))
app = create_app(config)
manager = Manager(app)


@manager.command
def validate():
    if app.template_service.validate():
        return 0
    else:
        return 1


manager.add_command('server', Server(host='0.0.0.0'))


if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO,
                        format="%(levelname)s: %(message)s")
    logging.getLogger('yorm').setLevel(logging.WARNING)
Пример #18
0
 def test_get_unknown(self):
     with pytest.raises(AssertionError):
         get_config('not_a_valid_config')
Пример #19
0
    def run(self):
        if app.template_service.validate():
            return 0
        else:
            return 1


def find_assets():
    """Yield paths for all static files and templates."""
    for name in ["static", "templates"]:
        directory = os.path.join(app.config["PATH"], name)
        for entry in os.scandir(directory):
            if entry.is_file():
                yield entry.path


# Select app configuration from the environment
config = get_config(os.getenv("FLASK_CONFIG", "dev"))

# Build the app using configuration from the environment
app = create_app(config)

# Configure the command-line interface
manager = Manager(app)
manager.add_command("validate", Validate())
manager.add_command("run", Server(host="0.0.0.0", extra_files=find_assets()))


if __name__ == "__main__":
    manager.run()
Пример #20
0
 def app():
     app = create_app(get_config('test'))
     app.config['GOOGLE_ANALYTICS_TID'] = 'my_tid'
     return app
Пример #21
0
#!env/bin/python

import os
import logging

from flask_script import Manager, Server

from memegen.settings import get_config
from memegen.app import create_app

config = get_config(os.getenv('CONFIG'))
app = create_app(config)
manager = Manager(app)


@manager.command
def validate():
    if app.template_service.validate():
        return 0
    else:
        return 1


manager.add_command('server', Server(host='0.0.0.0'))

if __name__ == '__main__':
    manager.run()
Пример #22
0
 def when_extended(expect):
     config = get_config('staging')
     expect(config.ENV) == 'staging'
Пример #23
0
def app():
    yield create_app(get_config('test'))
Пример #24
0
 def when_unknown(expect):
     with expect.raises(AssertionError):
         get_config('unknown')
Пример #25
0
#!env/bin/python

import os
import logging
from subprocess import check_output

from flask_script import Manager, Server
from flask_migrate import Migrate, MigrateCommand

from memegen.settings import get_config
from memegen.app import create_app

# Select app configuration from the environment
config = get_config(os.getenv('CONFIG', 'dev'))

# Build the app using configuration from the environment
app = create_app(config)

# Populate unset environment variables
for name, command in [
    ('DEPLOY_DATE', "TZ=America/Detroit date '+%F %T'"),
]:
    output = check_output(command, shell=True, universal_newlines=True).strip()
    os.environ[name] = os.getenv(name, output)

# Configure the command-line interface
manager = Manager(app)


@manager.command
def validate():
Пример #26
0
def app():
    app = create_app(get_config('test'))
    yield app
Пример #27
0
def unset(name):
    config = get_config('test')
    if getattr(config, name):
        return dict(condition=False, reason="")
    else:
        return dict(condition=True, reason="{} unset".format(name))
Пример #28
0
def app():
    yield create_app(get_config('test'))
Пример #29
0
#!env/bin/python

import os
import subprocess
import logging

from flask_script import Manager, Server
from flask_migrate import Migrate, MigrateCommand
from whitenoise import WhiteNoise

from memegen.settings import get_config
from memegen.app import create_app


# Select app configuration from the environment
config = get_config(os.getenv('CONFIG', 'dev'))

# Build the app using configuration from the environment
_app = create_app(config)

# Populate unset environment variables
for name, command in [
    ('DEPLOY_DATE', "TZ=America/Detroit date '+%F %T'"),
]:
    output = subprocess.run(command, shell=True, stdout=subprocess.PIPE,
                            universal_newlines=True).stdout.strip() or "???"
    os.environ[name] = os.getenv(name, output)

# Configure the command-line interface
manager = Manager(_app)
Пример #30
0
 def test_get_none(self):
     with pytest.raises(AssertionError):
         get_config('')
Пример #31
0
def app():
    app = create_app(get_config('test'))
    yield app
Пример #32
0
    def test_get_valid(self):
        config = get_config('prod')

        assert issubclass(config, Config)
        assert 'prod' == config.ENV
Пример #33
0
def app(postgres):
    app = create_app(get_config('test'))
    app.config['SQLALCHEMY_DATABASE_URI'] = postgres.url()
    yield app