def test_markovify_when_scrape_configured():
    app = create_app(TextScrapeTestConfig)

    with app.app_context():
        sample_text = placeholder_or_random_sample_text()

        # Give markovify a few more tries, if it fails to generate
        # text the first time.
        i = 0
        while i < 3 and (not sample_text):
            sample_text = placeholder_or_random_sample_text()
            i += 1

        assert sample_text is not None
        assert len(sample_text)
        assert sample_text != app.config['EDITABLE_PLACEHOLDER_TEXT']

        assert (
            ('and' in sample_text)
            or ('the' in sample_text)
            or ('that' in sample_text)
            or ('you' in sample_text)
            or ('man' in sample_text)
            or ('was' in sample_text)
            or ('with' in sample_text)
            or ('said' in sample_text)
            or ('him' in sample_text)
            or ('were' in sample_text))
示例#2
0
def app():
    _app = create_app(TestConfig)
    ctx = _app.test_request_context()
    ctx.push()

    yield _app

    ctx.pop()
示例#3
0
def test_sample_image_when_scrape_configured():
    app = create_app(ImageScrapeTestConfig)

    with app.app_context():
        sample_image = placeholder_or_random_sample_image()

        assert sample_image is not None
        assert len(sample_image)
        assert sample_image != app.config[
            'EDITABLE_PLACEHOLDER_IMAGE_RELATIVE_PATH']

        sample_image_filepath = os.path.abspath(
            os.path.join(app.config['MEDIA_FOLDER'], sample_image))

        assert os.path.exists(sample_image_filepath)
        os.remove(sample_image_filepath)
def test_sample_image_when_scrape_configured():
    app = create_app(ImageScrapeTestConfig)

    with app.app_context():
        sample_image = placeholder_or_random_sample_image()

        assert sample_image is not None
        assert len(sample_image)
        assert sample_image != app.config[
            'EDITABLE_PLACEHOLDER_IMAGE_RELATIVE_PATH']

        sample_image_filepath = os.path.abspath(os.path.join(
            app.config['MEDIA_FOLDER'],
            sample_image))

        assert os.path.exists(sample_image_filepath)
        os.remove(sample_image_filepath)
示例#5
0
def test_markovify_when_scrape_configured():
    app = create_app(TextScrapeTestConfig)

    with app.app_context():
        sample_text = placeholder_or_random_sample_text()

        # Give markovify a few more tries, if it fails to generate
        # text the first time.
        i = 0
        while i < 3 and (not sample_text):
            sample_text = placeholder_or_random_sample_text()
            i += 1

        assert sample_text is not None
        assert len(sample_text)
        assert sample_text != app.config['EDITABLE_PLACEHOLDER_TEXT']

        assert (('and' in sample_text) or ('the' in sample_text)
                or ('that' in sample_text) or ('you' in sample_text)
                or ('man' in sample_text) or ('was' in sample_text)
                or ('with' in sample_text) or ('said' in sample_text)
                or ('him' in sample_text) or ('were' in sample_text))
示例#6
0
def app_sessionstore():
    return create_app(SessionStoreTestConfig)
示例#7
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from flask_script import Manager, Shell, Server
from flask_script.commands import Clean, ShowUrls
from flask_migrate import MigrateCommand

from flask_editablesite.app import create_app
from flask_editablesite.user.commands import CreateUser
from flask_editablesite.editable.commands import DownloadSampleImages
from flask_editablesite.user.models import User
from flask_editablesite.settings import DevConfig, ProdConfig
from flask_editablesite.database import db

if os.environ.get("FLASK_EDITABLESITE_ENV") == 'prod':
    app = create_app(ProdConfig)
else:
    app = create_app(DevConfig)

HERE = os.path.abspath(os.path.dirname(__file__))
TEST_PATH = os.path.join(HERE, 'tests')

manager = Manager(app)


def _make_context():
    """Return context dict for a shell session so you can access
    app, db, and the User model by default.
    """
    return {'app': app, 'db': db, 'User': User}
示例#8
0
def test_production_config():
    app = create_app(ProdConfig)
    assert app.config['ENV'] == 'prod'
    assert app.config['DEBUG'] is False
    assert app.config['DEBUG_TB_ENABLED'] is False
    assert app.config['ASSETS_DEBUG'] is False
示例#9
0
def test_dev_config():
    app = create_app(DevConfig)
    assert app.config['ENV'] == 'dev'
    assert app.config['DEBUG'] is True
    assert app.config['ASSETS_DEBUG'] is True