File tree Expand file tree Collapse file tree 2 files changed +8
-12
lines changed Expand file tree Collapse file tree 2 files changed +8
-12
lines changed Original file line number Diff line number Diff line change 1414
1515"""App Engine app to serve as an endpoint for App Engine queue samples."""
1616
17- import logging
18-
1917from flask import Flask , request
2018
2119app = Flask (__name__ )
2523def log_payload ():
2624 """Log the request payload."""
2725 payload = request .get_data (as_text = True ) or '(empty payload)'
28- # Send our test logging message as a "warn" to ensure visibility.
29- logging .warn ('Received task with payload: {}' .format (payload ))
26+ print ('Received task with payload: {}' .format (payload ))
3027 return 'Printed task payload: {}' .format (payload )
3128
3229
Original file line number Diff line number Diff line change 1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15- import mock
1615import pytest
1716
1817
@@ -28,19 +27,19 @@ def test_index(app):
2827 assert r .status_code == 200
2928
3029
31- @mock .patch ('logging.warn' )
32- def test_log_payload (logging_mock , app ):
33- payload = 'hello'
30+ def test_log_payload (capsys , app ):
31+ payload = 'test_payload'
3432
3533 r = app .post ('/log_payload' , data = payload )
3634 assert r .status_code == 200
3735
38- assert logging_mock .called
36+ out , _ = capsys .readouterr ()
37+ assert payload in out
3938
4039
41- @mock .patch ('logging.warn' )
42- def test_empty_payload (logging_mock , app ):
40+ def test_empty_payload (capsys , app ):
4341 r = app .post ('/log_payload' )
4442 assert r .status_code == 200
4543
46- assert logging_mock .called
44+ out , _ = capsys .readouterr ()
45+ assert 'empty payload' in out
You can’t perform that action at this time.
0 commit comments