<s> import contextlib <EOL> import json <EOL> import mock <EOL> import testify as T <EOL> from pushmanager . core . util import get_servlet_urlspec <EOL> from pushmanager . servlets . pushitems import PushItemsServlet <EOL> from pushmanager . testing . testservlet import ServletTestMixin <EOL> class PushsItemsServletTest ( T . TestCase , ServletTestMixin ) : <EOL> def get_handlers ( self ) : <EOL> return [ <EOL> get_servlet_urlspec ( PushItemsServlet ) , <EOL> ] <EOL> @ T . setup <EOL> def setup_fake_requests_response ( self ) : <EOL> self . fake_request_data = { <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT:title>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT:user>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:10> , <EOL> "<STR_LIT:id>" : <NUM_LIT:1> <EOL> } <EOL> self . fake_requests_response = "<STR_LIT>" % json . dumps ( self . fake_request_data ) <EOL> def test_pushitems ( self ) : <EOL> with contextlib . nested ( <EOL> mock . patch . object ( PushItemsServlet , "<STR_LIT>" , return_value = self . fake_request_data [ "<STR_LIT:user>" ] ) , <EOL> mock . patch . object ( PushItemsServlet , "<STR_LIT>" , side_effect = self . mocked_api_call ) , <EOL> mock . patch . object ( self , "<STR_LIT>" , return_value = self . fake_requests_response ) <EOL> ) : <EOL> self . fetch ( "<STR_LIT>" % self . fake_request_data [ "<STR_LIT:id>" ] ) <EOL> response = self . wait ( ) <EOL> T . assert_in ( self . fake_request_data [ "<STR_LIT:title>" ] , response . body ) </s>
