<s> import datetime <EOL> from decimal import Decimal as D <EOL> from django . test import TestCase <EOL> from oscar . core . compat import get_user_model <EOL> from oscar . apps . payment . models import Bankcard , Source <EOL> class TestBankcard ( TestCase ) : <EOL> def test_obfuscates_number_before_saving ( self ) : <EOL> bankcard = Bankcard ( number = "<STR_LIT>" ) <EOL> bankcard . prepare_for_save ( ) <EOL> self . assertEqual ( "<STR_LIT>" , bankcard . number ) <EOL> def test_determines_bankcard_type ( self ) : <EOL> bankcard = Bankcard ( number = "<STR_LIT>" ) <EOL> self . assertEqual ( "<STR_LIT>" , bankcard . card_type ) <EOL> def test_provides_start_month_property ( self ) : <EOL> start = datetime . date ( day = <NUM_LIT:1> , month = <NUM_LIT:1> , year = <NUM_LIT> ) <EOL> bankcard = Bankcard ( start_date = start ) <EOL> self . assertEqual ( "<STR_LIT>" , bankcard . start_month ( ) ) <EOL> def test_provides_end_month_property ( self ) : <EOL> end = datetime . date ( day = <NUM_LIT:1> , month = <NUM_LIT:1> , year = <NUM_LIT> ) <EOL> bankcard = Bankcard ( expiry_date = end ) <EOL> self . assertEqual ( "<STR_LIT>" , bankcard . expiry_month ( ) ) <EOL> def test_bankcard_card_correct_save ( self ) : <EOL> user_klass = get_user_model ( ) <EOL> user = user_klass . objects . create_user ( '<STR_LIT:_>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> end = datetime . date ( day = <NUM_LIT:1> , month = <NUM_LIT:1> , year = <NUM_LIT> ) <EOL> bankcard = Bankcard . objects . create ( <EOL> user = user , number = "<STR_LIT>" , expiry_date = end ) <EOL> saved_bankcard = Bankcard . objects . get ( id = bankcard . id ) <EOL> self . assertEqual ( '<STR_LIT>' , saved_bankcard . card_type ) <EOL> class TestSource ( TestCase ) : <EOL> def test_calculates_initial_balance_correctly ( self ) : <EOL> source = Source ( amount_allocated = D ( '<STR_LIT:100>' ) ) <EOL> self . assertEqual ( D ( '<STR_LIT:100>' ) , source . balance ) <EOL> def test_calculates_balance_correctly ( self ) : <EOL> source = Source ( <EOL> amount_allocated = D ( '<STR_LIT:100>' ) , <EOL> amount_debited = D ( '<STR_LIT>' ) , <EOL> amount_refunded = D ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( <EOL> D ( '<STR_LIT:100>' ) - D ( '<STR_LIT>' ) + D ( '<STR_LIT>' ) , source . balance ) <EOL> def test_calculates_amount_for_refund_correctly ( self ) : <EOL> source = Source ( <EOL> amount_allocated = D ( '<STR_LIT:100>' ) , <EOL> amount_debited = D ( '<STR_LIT>' ) , <EOL> amount_refunded = D ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( <EOL> D ( '<STR_LIT>' ) - D ( '<STR_LIT>' ) , source . amount_available_for_refund ) </s>
