Skip to content

Commit

Permalink
Read from the config
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Jan 11, 2017
1 parent 98e0319 commit 97c7c18
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
1 change: 0 additions & 1 deletion memegen/settings.py
Expand Up @@ -28,7 +28,6 @@ class TestConfig(Config):

DEBUG = True
TESTING = True
REGENERATE_IMAGES = True


class DevConfig(Config):
Expand Down
22 changes: 15 additions & 7 deletions tests/test_images_examples.py
Expand Up @@ -2,16 +2,24 @@

# pylint: disable=bad-continuation

import os
from pathlib import Path

import pytest

from memegen.settings import get_config


ENV = 'REGENERATE_IMAGES'
SAMPLES = Path(__file__).parent.joinpath("examples")


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))


def save_image(client, url, name):
response = client.get(url)
data = response.get_data()
Expand All @@ -20,8 +28,8 @@ def save_image(client, url, name):
image.write(data)


@pytest.mark.skipif(not os.getenv(ENV), reason="{} unset".format(ENV))
def test_text(client):
@pytest.mark.skipif(**unset('REGENERATE_IMAGES'))
def test_text_wrapping(client):
"""Create various example images for manual verification."""
for name, url in [
("text-basic.jpg", "/ch/hello/world.jpg"),
Expand All @@ -33,7 +41,7 @@ def test_text(client):
save_image(client, url, name)


@pytest.mark.skipif(not os.getenv(ENV), reason="{} unset".format(ENV))
@pytest.mark.skipif(**unset('REGENERATE_IMAGES'))
def test_standard_font(client):
"""Create a meme using the standard meme font.
Expand All @@ -44,14 +52,14 @@ def test_standard_font(client):
save_image(client, url, "font-impact.jpg")


@pytest.mark.skipif(not os.getenv(ENV), reason="{} unset".format(ENV))
@pytest.mark.skipif(**unset('REGENERATE_IMAGES'))
def test_japanese_font(client):
"""Create a meme using a font that supports Japanese characters."""
url = "/ch/turning/日本語.jpg?font=notosanscjkjp-black"
save_image(client, url, "font-notosans.jpg")


@pytest.mark.skipif(not os.getenv(ENV), reason="{} unset".format(ENV))
@pytest.mark.skipif(**unset('REGENERATE_IMAGES'))
def test_custom_sizes(client):
"""Create memes using custom sizes."""
for name, url in [
Expand Down

0 comments on commit 97c7c18

Please sign in to comment.