# Path: flask_editablesite/app.py
# def create_app(config_object=ProdConfig):
#     """An application factory, as explained here:
#         http://flask.pocoo.org/docs/patterns/appfactories/
# 
#     :param config_object: The configuration object to use.
#     """
#     app = Flask(__name__)
#     app.config.from_object(config_object)
#     register_loggers(app)
#     register_extensions(app)
#     register_blueprints(app)
#     register_errorhandlers(app)
#     return app
# 
# Path: flask_editablesite/settings.py
# class TestConfig(Config):
#     TESTING = True
#     DEBUG = True
#     BCRYPT_LOG_ROUNDS = 1  # For faster tests
#     WTF_CSRF_ENABLED = False  # Allows form testing
# 
# Path: flask_editablesite/editable/sample_images.py
# def placeholder_or_random_sample_image():
#     """
#     Gets a random sample image if possible, otherwise the default
#     placeholder image.
#     """
# 
#     is_sample_images_configured = (
#         app.config.get('EDITABLE_SAMPLE_IMAGES_SCRAPE_URL') and
#         app.config.get('EDITABLE_SAMPLE_IMAGES_RELATIVE_PATH'))
# 
#     return (is_sample_images_configured
#             and random_sample_image()
#             or app.config['EDITABLE_PLACEHOLDER_IMAGE_RELATIVE_PATH'])


import os
from flask_editablesite.app import create_app
from flask_editablesite.settings import TestConfig
from flask_editablesite.editable.sample_images import (
    placeholder_or_random_sample_image,)
# -*- coding: utf-8 -*-
"""Test the sample image selection."""






def test_placeholder_when_no_sample_images_configured(app):
    sample_image = placeholder_or_random_sample_image()
    assert sample_image == app.config[
        'EDITABLE_PLACEHOLDER_IMAGE_RELATIVE_PATH']


class ImageScrapeTestConfig(TestConfig):
    EDITABLE_SAMPLE_IMAGES_SCRAPE_URL = (
        'http://www.psych.usyd.edu.au/pdp-11/Images/Images.html')
    EDITABLE_SAMPLE_IMAGES_SCRAPE_PARENTELNAME = 'li'
    EDITABLE_SAMPLE_IMAGES_RELATIVE_PATH = 'pdp11/'


def test_sample_image_when_scrape_configured():
    app = create_app(ImageScrapeTestConfig)

    with app.app_context():

# Path: flask_editablesite/app.py
# def create_app(config_object=ProdConfig):
#     """An application factory, as explained here:
#         http://flask.pocoo.org/docs/patterns/appfactories/
# 
#     :param config_object: The configuration object to use.
#     """
#     app = Flask(__name__)
#     app.config.from_object(config_object)
#     register_loggers(app)
#     register_extensions(app)
#     register_blueprints(app)
#     register_errorhandlers(app)
#     return app
# 
# Path: flask_editablesite/settings.py
# class TestConfig(Config):
#     TESTING = True
#     DEBUG = True
#     BCRYPT_LOG_ROUNDS = 1  # For faster tests
#     WTF_CSRF_ENABLED = False  # Allows form testing
# 
# Path: flask_editablesite/editable/sample_images.py
# def placeholder_or_random_sample_image():
#     """
#     Gets a random sample image if possible, otherwise the default
#     placeholder image.
#     """
# 
#     is_sample_images_configured = (
#         app.config.get('EDITABLE_SAMPLE_IMAGES_SCRAPE_URL') and
#         app.config.get('EDITABLE_SAMPLE_IMAGES_RELATIVE_PATH'))
# 
#     return (is_sample_images_configured
#             and random_sample_image()
#             or app.config['EDITABLE_PLACEHOLDER_IMAGE_RELATIVE_PATH'])


# Path: tests/test_sample_images.py
import os
from flask_editablesite.app import create_app
from flask_editablesite.settings import TestConfig
from flask_editablesite.editable.sample_images import (
    placeholder_or_random_sample_image,)

# -*- coding: utf-8 -*-
"""Test the sample image selection."""






def test_placeholder_when_no_sample_images_configured(app):
    sample_image = placeholder_or_random_sample_image()
    assert sample_image == app.config[
        'EDITABLE_PLACEHOLDER_IMAGE_RELATIVE_PATH']


class ImageScrapeTestConfig(TestConfig):
    EDITABLE_SAMPLE_IMAGES_SCRAPE_URL = (
        'http://www.psych.usyd.edu.au/pdp-11/Images/Images.html')
    EDITABLE_SAMPLE_IMAGES_SCRAPE_PARENTELNAME = 'li'
    EDITABLE_SAMPLE_IMAGES_RELATIVE_PATH = 'pdp11/'


def test_sample_image_when_scrape_configured():
    app = create_app(ImageScrapeTestConfig)

    with app.app_context():

        sample_image = placeholder_or_random_sample_image()