<s> import os <EOL> import sys <EOL> import unittest <EOL> from mock import patch <EOL> import shippo <EOL> from shippo . test . helper import ShippoTestCase <EOL> import test_shipment <EOL> sys . path . insert ( <NUM_LIT:0> , os . path . join ( os . path . dirname ( __file__ ) , '<STR_LIT:..>' , '<STR_LIT:..>' ) ) <EOL> class RateTests ( ShippoTestCase ) : <EOL> request_client = shippo . http_client . RequestsClient <EOL> def setUp ( self ) : <EOL> super ( RateTests , self ) . setUp ( ) <EOL> def get_http_client ( * args , ** kwargs ) : <EOL> return self . request_client ( * args , ** kwargs ) <EOL> self . client_patcher = patch ( <EOL> '<STR_LIT>' ) <EOL> client_mock = self . client_patcher . start ( ) <EOL> client_mock . side_effect = get_http_client <EOL> def tearDown ( self ) : <EOL> super ( RateTests , self ) . tearDown ( ) <EOL> self . client_patcher . stop ( ) <EOL> def test_retrieve ( self ) : <EOL> shipment = test_shipment . create_mock_shipment ( ) <EOL> rates = shippo . Shipment . get_rates ( shipment . object_id , sync = True ) <EOL> rate = rates . results [ <NUM_LIT:0> ] <EOL> retrieve = shippo . Rate . retrieve ( rate . object_id ) <EOL> self . assertItemsEqual ( rate , retrieve ) <EOL> def test_invalid_retrieve ( self ) : <EOL> self . assertRaises ( shippo . error . APIError , shippo . Rate . retrieve , '<STR_LIT>' ) <EOL> def test_list_all ( self ) : <EOL> rate_list = shippo . Rate . all ( ) <EOL> self . assertTrue ( '<STR_LIT:count>' in rate_list ) <EOL> self . assertTrue ( '<STR_LIT>' in rate_list ) <EOL> def test_list_page_size ( self ) : <EOL> pagesize = <NUM_LIT:1> <EOL> rate_list = shippo . Rate . all ( size = pagesize ) <EOL> self . assertEquals ( len ( rate_list . results ) , pagesize ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
