Example #1
0
def app():
    return create_app(get_config('test'))
Example #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()
Example #3
0
 def when_empty(expect):
     with expect.raises(AssertionError):
         get_config('')
Example #4
0
 def when_valid(expect):
     config = get_config('production')
     expect(config.ENV) == 'production'
Example #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
Example #7
0
 def app():
     app = create_app(get_config("test"))
     app.config["GOOGLE_ANALYTICS_TID"] = "my_tid"
     return app
Example #8
0
 def test_get_none(self):
     with pytest.raises(AssertionError):
         get_config('')
Example #9
0
 def when_unknown(expect):
     with expect.raises(AssertionError):
         get_config('unknown')
Example #10
0
 def when_valid(expect):
     config = get_config('production')
     expect(config.ENV) == 'production'
Example #11
0
 def when_empty(expect):
     with expect.raises(AssertionError):
         get_config('')
Example #12
0
 def when_extended(expect):
     config = get_config('staging')
     expect(config.ENV) == 'staging'
Example #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()
Example #14
0
 def test_get_unknown(self):
     with pytest.raises(AssertionError):
         get_config('not_a_valid_config')
Example #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()
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))
Example #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)
Example #18
0
 def test_get_unknown(self):
     with pytest.raises(AssertionError):
         get_config('not_a_valid_config')
Example #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()
Example #20
0
 def app():
     app = create_app(get_config('test'))
     app.config['GOOGLE_ANALYTICS_TID'] = 'my_tid'
     return app
Example #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()
Example #22
0
 def when_extended(expect):
     config = get_config('staging')
     expect(config.ENV) == 'staging'
Example #23
0
def app():
    yield create_app(get_config('test'))
Example #24
0
 def when_unknown(expect):
     with expect.raises(AssertionError):
         get_config('unknown')
Example #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():
Example #26
0
def app():
    app = create_app(get_config('test'))
    yield app
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))
Example #28
0
def app():
    yield create_app(get_config('test'))
Example #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)
Example #30
0
 def test_get_none(self):
     with pytest.raises(AssertionError):
         get_config('')
Example #31
0
def app():
    app = create_app(get_config('test'))
    yield app
Example #32
0
    def test_get_valid(self):
        config = get_config('prod')

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