<s> from roost . httpclient import * <EOL> from twisted . trial import unittest <EOL> from twisted . web import client <EOL> from mock import MagicMock , Mock , patch <EOL> from StringIO import StringIO <EOL> class HttpclientTestCase ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . request_patcher = patch . object ( client . Agent , '<STR_LIT>' ) <EOL> self . mock_request = self . request_patcher . start ( ) <EOL> def tearDown ( self ) : <EOL> self . request_patcher . stop ( ) <EOL> def assert_body ( self , url , expected_body ) : <EOL> self . assertEquals ( self . mock_request . call_args [ <NUM_LIT:0> ] , ( '<STR_LIT:POST>' , url ) ) <EOL> kwargs = self . mock_request . call_args [ <NUM_LIT:1> ] <EOL> stringIO = StringIO ( ) <EOL> kwargs [ '<STR_LIT>' ] . startProducing ( stringIO ) <EOL> self . assertEquals ( stringIO . getvalue ( ) , expected_body ) <EOL> def test_post_with_body ( self ) : <EOL> post ( '<STR_LIT>' , "<STR_LIT>" ) <EOL> self . assert_body ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def test_post_with_keywords ( self ) : <EOL> post ( '<STR_LIT>' , value1 = '<STR_LIT>' , value2 = '<STR_LIT>' ) <EOL> self . assert_body ( '<STR_LIT>' , "<STR_LIT>" ) </s>
