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))
def app(): _app = create_app(TestConfig) ctx = _app.test_request_context() ctx.push() yield _app ctx.pop()
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)
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))
def app_sessionstore(): return create_app(SessionStoreTestConfig)
#!/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}
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
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