Skip to content

Commit

Permalink
test(success): magicmock
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Holík authored and sladg committed Apr 25, 2023
1 parent b5b8c96 commit f5dc6b1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/test_success.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest

from imaginex_lambda.handler import handler, S3_BUCKET_NAME, download_and_optimize
from unittest.mock import MagicMock


def test_handler_success():
Expand All @@ -16,10 +17,9 @@ def test_handler_success():
"""

context = {'queryStringParameters': {'url': 'abc.png', 'q': '50', 'w': '100'}}
fake_optimization_return = (b'abcdef', 'application/someimage', 0.3)
fake_optimization_return = MagicMock(return_value=((b'abcdef', 'application/someimage', 0.3)))

with patch('imaginex_lambda.handler.download_and_optimize') as p:
p.return_value = fake_optimization_return
with patch('imaginex_lambda.handler.download_and_optimize', fake_optimization_return) as p:
r = handler(context, None)

assert r['statusCode'] == 200
Expand Down

0 comments on commit f5dc6b1

Please sign in to comment.