# Path: balanced/exc.py
# class BalancedError(Exception):
# class ResourceError(BalancedError):
# class NoResultFound(BalancedError):
# class MultipleResultsFound(BalancedError):
# class FundingSourceNotCreditable(Exception):
# class HTTPError(BalancedError, wac.Error):
#     class __metaclass__(type):
# class FundingInstrumentVerificationFailure(HTTPError):
# class BankAccountVerificationFailure(FundingInstrumentVerificationFailure):
#     def __str__(self):
# def convert_error(ex):
#         def __new__(meta_cls, name, bases, dikt):
#     def __init__(self, requests_ex):
#     def format_message(cls, requests_ex):
#     def from_response(cls, **data):
#     AUTH_NOT_PENDING = 'bank-account-authentication-not-pending'
#     AUTH_FAILED = 'bank-account-authentication-failed'
#     AUTH_DUPLICATED = 'bank-account-authentication-already-exists'


import sys
import time
import unittest2 as unittest
import requests
import balanced
from datetime import date
from balanced import exc as bexc
        self.assertEqual(credit.amount, 1000)
        with self.assertRaises(requests.HTTPError) as exc:
            bank_account.credit(amount=(debit.amount - credit.amount) + 1)
        self.assertEqual(exc.exception.status_code, 409)
        self.assertEqual(exc.exception.category_code, 'insufficient-funds')

    def test_credit_existing_card(self):
        funding_card = balanced.Card(**CARD).save()
        card = balanced.Card(**CREDITABLE_CARD).save()
        debit = funding_card.debit(amount=250000)
        credit = card.credit(amount=250000)
        self.assertTrue(credit.id.startswith('CR'))
        self.assertEqual(credit.href, '/credits/{0}'.format(credit.id))
        self.assertEqual(credit.status, 'succeeded')
        self.assertEqual(credit.amount, 250000)

    def test_credit_card_in_request(self):
        funding_card = balanced.Card(**CARD).save()
        debit = funding_card.debit(amount=250000)
        credit = balanced.Credit(
            amount=250000,
            description='A sweet ride',
            destination=CREDITABLE_CARD
        ).save()
        self.assertTrue(credit.id.startswith('CR'))
        self.assertEqual(credit.href, '/credits/{0}'.format(credit.id))
        self.assertEqual(credit.status, 'succeeded')
        self.assertEqual(credit.amount, 250000)
        self.assertEqual(credit.description, 'A sweet ride')


# Path: balanced/exc.py
# class BalancedError(Exception):
# class ResourceError(BalancedError):
# class NoResultFound(BalancedError):
# class MultipleResultsFound(BalancedError):
# class FundingSourceNotCreditable(Exception):
# class HTTPError(BalancedError, wac.Error):
#     class __metaclass__(type):
# class FundingInstrumentVerificationFailure(HTTPError):
# class BankAccountVerificationFailure(FundingInstrumentVerificationFailure):
#     def __str__(self):
# def convert_error(ex):
#         def __new__(meta_cls, name, bases, dikt):
#     def __init__(self, requests_ex):
#     def format_message(cls, requests_ex):
#     def from_response(cls, **data):
#     AUTH_NOT_PENDING = 'bank-account-authentication-not-pending'
#     AUTH_FAILED = 'bank-account-authentication-failed'
#     AUTH_DUPLICATED = 'bank-account-authentication-already-exists'


# Path: tests/test_suite.py
import sys
import time
import unittest2 as unittest
import requests
import balanced
from datetime import date
from balanced import exc as bexc

        self.assertEqual(credit.amount, 1000)
        with self.assertRaises(requests.HTTPError) as exc:
            bank_account.credit(amount=(debit.amount - credit.amount) + 1)
        self.assertEqual(exc.exception.status_code, 409)
        self.assertEqual(exc.exception.category_code, 'insufficient-funds')

    def test_credit_existing_card(self):
        funding_card = balanced.Card(**CARD).save()
        card = balanced.Card(**CREDITABLE_CARD).save()
        debit = funding_card.debit(amount=250000)
        credit = card.credit(amount=250000)
        self.assertTrue(credit.id.startswith('CR'))
        self.assertEqual(credit.href, '/credits/{0}'.format(credit.id))
        self.assertEqual(credit.status, 'succeeded')
        self.assertEqual(credit.amount, 250000)

    def test_credit_card_in_request(self):
        funding_card = balanced.Card(**CARD).save()
        debit = funding_card.debit(amount=250000)
        credit = balanced.Credit(
            amount=250000,
            description='A sweet ride',
            destination=CREDITABLE_CARD
        ).save()
        self.assertTrue(credit.id.startswith('CR'))
        self.assertEqual(credit.href, '/credits/{0}'.format(credit.id))
        self.assertEqual(credit.status, 'succeeded')
        self.assertEqual(credit.amount, 250000)
        self.assertEqual(credit.description, 'A sweet ride')


    def test_credit_card_can_credit_false(self):