<s> from tests . test_helper import * <EOL> from braintree . test . credit_card_numbers import CreditCardNumbers <EOL> class TestVerificationSearch ( unittest . TestCase ) : <EOL> def test_advanced_search_no_results ( self ) : <EOL> collection = CreditCardVerification . search ( [ <EOL> CreditCardVerificationSearch . credit_card_cardholder_name == "<STR_LIT>" ] ) <EOL> self . assertEquals ( <NUM_LIT:0> , collection . maximum_size ) <EOL> def test_search_on_verification_id ( self ) : <EOL> customer_id = "<STR_LIT:%s>" % randint ( <NUM_LIT:1> , <NUM_LIT> ) <EOL> result = Customer . create ( { <EOL> "<STR_LIT:id>" : customer_id , <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : CreditCardNumbers . FailsSandboxVerification . Visa , <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : True <EOL> } <EOL> } <EOL> } ) <EOL> verification_id = result . credit_card_verification . id <EOL> found_verifications = CreditCardVerification . search ( <EOL> CreditCardVerificationSearch . id == verification_id <EOL> ) <EOL> self . assertEqual ( <NUM_LIT:1> , found_verifications . maximum_size ) <EOL> self . assertEqual ( verification_id , found_verifications . first . id ) <EOL> def test_all_text_fields ( self ) : <EOL> email = "<STR_LIT>" <EOL> cardholder_name = "<STR_LIT>" % randint ( <NUM_LIT:1> , <NUM_LIT> ) <EOL> customer_id = "<STR_LIT:%s>" % randint ( <NUM_LIT:1> , <NUM_LIT> ) <EOL> expiration_date = "<STR_LIT>" <EOL> number = CreditCardNumbers . MasterCard <EOL> postal_code = "<STR_LIT>" <EOL> customer = Customer . create ( { <EOL> "<STR_LIT:id>" : customer_id , <EOL> "<STR_LIT:email>" : email , <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : cardholder_name , <EOL> "<STR_LIT>" : expiration_date , <EOL> "<STR_LIT>" : number , <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : postal_code <EOL> } , <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : True <EOL> } <EOL> } <EOL> } ) . customer <EOL> found_verifications = CreditCardVerification . search ( <EOL> CreditCardVerificationSearch . credit_card_expiration_date == expiration_date , <EOL> CreditCardVerificationSearch . credit_card_cardholder_name == cardholder_name , <EOL> CreditCardVerificationSearch . credit_card_number == number , <EOL> CreditCardVerificationSearch . customer_email == email , <EOL> CreditCardVerificationSearch . customer_id == customer_id , <EOL> CreditCardVerificationSearch . billing_postal_code == postal_code <EOL> ) <EOL> self . assertEqual ( <NUM_LIT:1> , found_verifications . maximum_size ) <EOL> self . assertEqual ( customer . credit_cards [ <NUM_LIT:0> ] . token , found_verifications . first . credit_card [ "<STR_LIT>" ] ) <EOL> def test_multiple_value_fields ( self ) : <EOL> cardholder_name = "<STR_LIT>" % randint ( <NUM_LIT:1> , <NUM_LIT> ) <EOL> number = CreditCardNumbers . FailsSandboxVerification . MasterCard <EOL> unsuccessful_result1 = Customer . create ( { "<STR_LIT>" : { <EOL> "<STR_LIT>" : cardholder_name , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : number , <EOL> "<STR_LIT>" : { "<STR_LIT>" : True } <EOL> } } ) <EOL> cardholder_name = "<STR_LIT>" % randint ( <NUM_LIT:1> , <NUM_LIT> ) <EOL> number = CreditCardNumbers . FailsSandboxVerification . Visa <EOL> unsuccessful_result2 = Customer . create ( { "<STR_LIT>" : { <EOL> "<STR_LIT>" : cardholder_name , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : number , <EOL> "<STR_LIT>" : { "<STR_LIT>" : True } <EOL> } } ) <EOL> verification1 = unsuccessful_result1 . credit_card_verification <EOL> verification2 = unsuccessful_result2 . credit_card_verification <EOL> search_results = CreditCardVerification . search ( <EOL> CreditCardVerificationSearch . ids . in_list ( [ <EOL> verification1 . id , verification2 . id ] ) , <EOL> CreditCardVerificationSearch . credit_card_card_type . in_list ( [ <EOL> verification1 . credit_card [ "<STR_LIT>" ] , verification2 . credit_card [ "<STR_LIT>" ] ] ) , <EOL> CreditCardVerificationSearch . status . in_list ( [ <EOL> verification1 . status , verification2 . status ] ) <EOL> ) <EOL> self . assertEquals ( <NUM_LIT:2> , search_results . maximum_size ) <EOL> def test_range_field ( self ) : <EOL> cardholder_name = "<STR_LIT>" % randint ( <NUM_LIT:1> , <NUM_LIT> ) <EOL> number = CreditCardNumbers . FailsSandboxVerification . MasterCard <EOL> unsuccessful_result = Customer . create ( { "<STR_LIT>" : { <EOL> "<STR_LIT>" : cardholder_name , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : number , <EOL> "<STR_LIT>" : { "<STR_LIT>" : True } <EOL> } } ) <EOL> created_verification = unsuccessful_result . credit_card_verification <EOL> created_time = created_verification . created_at <EOL> before_creation = created_time - timedelta ( minutes = <NUM_LIT:10> ) <EOL> after_creation = created_time + timedelta ( minutes = <NUM_LIT:10> ) <EOL> found_verifications = CreditCardVerification . search ( <EOL> CreditCardVerificationSearch . id == created_verification . id , <EOL> CreditCardVerificationSearch . created_at . between ( before_creation , after_creation ) ) <EOL> self . assertEquals ( <NUM_LIT:1> , found_verifications . maximum_size ) <EOL> way_before_creation = created_time - timedelta ( minutes = <NUM_LIT:10> ) <EOL> just_before_creation = created_time - timedelta ( minutes = <NUM_LIT:1> ) <EOL> found_verifications = CreditCardVerification . search ( <EOL> CreditCardVerificationSearch . id == created_verification . id , <EOL> CreditCardVerificationSearch . created_at . between ( way_before_creation , just_before_creation ) ) <EOL> self . assertEquals ( <NUM_LIT:0> , found_verifications . maximum_size ) <EOL> found_verifications = CreditCardVerification . search ( <EOL> CreditCardVerificationSearch . id == created_verification . id , <EOL> CreditCardVerificationSearch . created_at == created_time ) <EOL> self . assertEquals ( <NUM_LIT:1> , found_verifications . maximum_size ) </s>
