Skip to content

Commit

Permalink
Add integration tests for hidden images
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Jun 16, 2015
1 parent e0698b2 commit 9d198ee
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion memegen/services/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __init__(self, template_store, image_store, **kwargs):
def find_template(self, template):
template = self.template_store.read(template)
if not template:
raise self.exceptions.missing
raise self.exceptions.not_found
return template

def create_image(self, template, text, kind):
Expand Down
6 changes: 6 additions & 0 deletions memegen/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@
@pytest.fixture
def link_service():
return services.link.LinkService(template_store=Mock())


@pytest.fixture
def image_service():
return services.image.ImageService(template_store=Mock(),
image_store=Mock())
10 changes: 10 additions & 0 deletions memegen/test/test_services_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import pytest


class TestImageService:

def test_find_template_not_found(self, image_service):
image_service.template_store.read.return_value = None

with pytest.raises(KeyError):
image_service.find_template("unknown")
1 change: 0 additions & 1 deletion scent.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def python_tests(*_):

for count, (command, title) in enumerate((
(('make', 'test-unit'), "Unit Tests"),
(('make', 'test-int'), "Integration Tests"),
(('make', 'test-all'), "Combined Tests"),
(('make', 'check'), "Static Analysis"),
(('make', 'doc'), None),
Expand Down
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def load(response):
return data



@pytest.fixture
def app():
return create_app(get_config('test'))
Expand Down
13 changes: 9 additions & 4 deletions tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,33 @@

class TestMeme:

def test_get_jpg(self, client):
def test_get_visible_jpg(self, client):
response = client.get("/iw/hello/world.jpg")
assert response.status_code == 200
assert response.mimetype == 'image/jpeg'

# TODO: add more image types

# def test_get_jpeg(self, client):
# def test_get_visible_jpeg(self, client):
# response = client.get("/iw/hello/world.jpeg")
# assert response.status_code == 200
# assert response.mimetype == 'image/jpeg'

# def test_get_png(self, client):
# def test_get_visible_png(self, client):
# response = client.get("/iw/hello/world.png")
# assert response.status_code == 200
# assert response.mimetype == 'image/png'

# def test_get_gif(self, client):
# def test_get_visible_gif(self, client):
# response = client.get("/iw/hello/world.gif")
# assert response.status_code == 200
# assert response.mimetype == 'image/gif'

def test_get_hidden_jpg(self, client):
response = client.get("/aXcJaGVsbG8Jd29ybGQg.jpg")
assert response.status_code == 200
assert response.mimetype == 'image/jpeg'


class TestLink:

Expand Down

0 comments on commit 9d198ee

Please sign in to comment.