<s> from tests . test_helper import * <EOL> from braintree . payment_method_gateway import PaymentMethodGateway <EOL> class TestPaymentMethodGateway ( unittest . TestCase ) : <EOL> def test_parse_response_returns_a_credit_card ( self ) : <EOL> payment_method_gateway = PaymentMethodGateway ( BraintreeGateway ( None ) ) <EOL> credit_card = payment_method_gateway . _parse_payment_method ( { <EOL> "<STR_LIT>" : { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } <EOL> } ) <EOL> self . assertEquals ( credit_card . __class__ , CreditCard ) <EOL> self . assertEquals ( credit_card . bin , "<STR_LIT>" ) <EOL> self . assertEquals ( credit_card . last_4 , "<STR_LIT>" ) <EOL> def test_parse_response_returns_a_paypal_account ( self ) : <EOL> payment_method_gateway = PaymentMethodGateway ( BraintreeGateway ( None ) ) <EOL> paypal_account = payment_method_gateway . _parse_payment_method ( { <EOL> "<STR_LIT>" : { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT:default>" : False } <EOL> } ) <EOL> self . assertEquals ( paypal_account . __class__ , PayPalAccount ) <EOL> self . assertEquals ( paypal_account . token , "<STR_LIT>" ) <EOL> self . assertFalse ( paypal_account . default ) <EOL> def test_parse_response_returns_an_unknown_payment_method ( self ) : <EOL> payment_method_gateway = PaymentMethodGateway ( BraintreeGateway ( None ) ) <EOL> unknown_payment_method = payment_method_gateway . _parse_payment_method ( { <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT:default>" : True , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } <EOL> } ) <EOL> self . assertEquals ( unknown_payment_method . __class__ , UnknownPaymentMethod ) <EOL> self . assertEquals ( unknown_payment_method . token , "<STR_LIT>" ) <EOL> self . assertTrue ( unknown_payment_method . default ) <EOL> def test_create_signature ( self ) : <EOL> actual_signature = PaymentMethod . signature ( "<STR_LIT>" ) <EOL> expected_signature = [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> { <EOL> "<STR_LIT>" : Address . create_signature ( ) } , <EOL> { <EOL> "<STR_LIT>" : [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> ] <EOL> } <EOL> ] <EOL> self . assertEqual ( expected_signature , actual_signature ) <EOL> def test_update_signature ( self ) : <EOL> actual_signature = PaymentMethod . update_signature ( ) <EOL> expected_signature = [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> { <EOL> "<STR_LIT>" : [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> ] <EOL> } , <EOL> { <EOL> "<STR_LIT>" : Address . update_signature ( ) + [ { "<STR_LIT>" : [ "<STR_LIT>" ] } ] <EOL> } <EOL> ] <EOL> self . assertEqual ( expected_signature , actual_signature ) <EOL> def test_nonce_grant_params ( self ) : <EOL> """<STR_LIT>""" <EOL> payment_method_gateway = PaymentMethodGateway ( BraintreeGateway ( None ) ) <EOL> with self . assertRaises ( ValueError ) : <EOL> payment_method_gateway . grant ( "<STR_LIT>" , False ) <EOL> with self . assertRaises ( ValueError ) : <EOL> payment_method_gateway . grant ( "<STR_LIT:\t>" , False ) <EOL> with self . assertRaises ( ValueError ) : <EOL> payment_method_gateway . grant ( None , False ) <EOL> def test_nonce_revoke_params ( self ) : <EOL> payment_method_gateway = PaymentMethodGateway ( BraintreeGateway ( None ) ) <EOL> with self . assertRaises ( ValueError ) : <EOL> payment_method_gateway . revoke ( "<STR_LIT>" ) <EOL> with self . assertRaises ( ValueError ) : <EOL> payment_method_gateway . revoke ( "<STR_LIT:\t>" ) <EOL> with self . assertRaises ( ValueError ) : <EOL> payment_method_gateway . revoke ( None ) </s>
