コード例 #1
0
  def test_month_invoice_from_person(self):
    from transaction import Transaction

    with Stub() as first_person: first_person.id >> 1

    # Credit card for first person only.
    self.credit_card.person_id = first_person.id

    with Stub() as first_transaction:
      first_transaction.credit_card_id >> self.credit_card.id
      first_transaction.value >> 100.50
      first_transaction.month >> 10

    with Stub() as second_transaction:
      second_transaction.credit_card_id >> self.credit_card.id
      second_transaction.value >> 200.10
      second_transaction.month >> 10

    with Stub() as third_transaction:
      third_transaction.credit_card_id >> self.credit_card.id
      third_transaction.value >> 50.20
      third_transaction.month >> 11

    Transaction.objects = { 1: first_transaction,
                            2: second_transaction,
                            3: third_transaction }

    CreditCard.month_invoice_from_person(10, first_person) |should| equal_to(
      300.60
    )
コード例 #2
0
def main(av):
    if len(av) != 2:
        print("USAGE: " + av[0] + " card_number")
    else:
        card = CreditCard(av[1])
        for possibility in card.get_all_possibilities():
            print(possibility)
コード例 #3
0
    def test_credit_card_4329876355493470(self):
        cc = CreditCard('4329876355493470')

        self.assertFalse(cc.valid, msg="This card does not meet mod10")
        self.assertEqual(cc.card_type,
                         "INVALID",
                         msg="card_type should be INVALID")
コード例 #4
0
    def test_credit_card_5515460934365316(self):
        cc = CreditCard('5515460934365316')

        self.assertTrue(cc.valid, msg="Mastercard is Valid")
        self.assertEqual(cc.card_type,
                         "MASTERCARD",
                         msg="card_type is MASTERCARD")
コード例 #5
0
    def test_credit_card_4440(self):
        cc = CreditCard('4440')

        self.assertFalse(cc.valid, msg="4440 is too short to be valid")
        self.assertEqual(cc.card_type,
                         "INVALID",
                         msg="4440 card type should be INVALID")
コード例 #6
0
    def test_credit_card_9999999999999999(self):
        cc = CreditCard('9999999999999999')

        self.assertFalse(cc.valid,
                         msg="Credit Card number cannot start with 9")
        self.assertEqual(cc.card_type,
                         "INVALID",
                         msg="99... card type is 'INVALID'")
コード例 #7
0
    def test_credit_card_339179199857685(self):
        cc = CreditCard('339179199857685')

        self.assertFalse(
            cc.valid,
            msg="Validates mod10, but invalid starting numbers for AMEX")
        self.assertEqual(cc.card_type,
                         "INVALID",
                         msg="card_type should be INVALID")
コード例 #8
0
  def test_month_transactions(self):
    from transaction import Transaction

    with Stub() as first_transaction:
      first_transaction.month >> 10

    with Stub() as second_transaction:
      second_transaction.month >> 10

    with Stub() as third_transaction:
      third_transaction.month >> 11

    Transaction.objects = { 1: first_transaction,
                            2: second_transaction,
                            3: third_transaction }

    # October's transactions
    CreditCard.month_transactions(10) |should| equal_to(
      [first_transaction, second_transaction]
    )
コード例 #9
0
ファイル: payment_method.py プロジェクト: pitchup/spreedly-py
    def from_xml(cls, xml_doc):
        from paypal import Paypal
        from credit_card import CreditCard

        payment_method_xml = xml_doc.xpath('.//payment_method_type')[0]

        payment_method = payment_method_xml.text

        if payment_method == 'credit_card':
            return CreditCard(xml_doc)
        elif payment_method == 'paypal':
            return Paypal(xml_doc)
        elif payment_method == 'sprel':
            return Sprel(xml_doc)
        elif payment_method == 'bank_account':
            return BankAccount(xml_doc)
コード例 #10
0
 def transfer_welcome_processing(self, data):
     if self.session_card_number == data:
         print("You can't transfer money to the same account!")
         self.state = State.IN_ACCOUNT
         return
     if not CreditCard.ctrl_checksum(data):
         print(
             "Probably you made a mistake in the card number. Please try again!"
         )
         self.state = State.IN_ACCOUNT
         return
     if not self.storage.find_user(data):
         print("Such a card does not exist.")
         self.state = State.IN_ACCOUNT
         return
     self.transfer_dst = data
     self.state = State.TRANS_MONEY
コード例 #11
0
class CreditCardTestCase(unittest.TestCase):
    def setUp(self):
        self.cc = CreditCard('John Doe', 'JD Bank', '12345', 1000)

    def tearDown(self):
        del self.cc

    def test_credit_card_charge(self):
        self.assertFalse(self.cc.charge(1001),
                         'allowed a charge above the limit')
        self.assertTrue(self.cc.charge(500),
                        'failed to complete a valid charge')
        self.assertEqual(self.cc.get_balance(), 500,
                         'incorrect balance after charge')

    def test_make_credit_card_charge(self):
        self.cc.charge(500)
        self.cc.make_payment(250)
        self.assertEqual(self.cc.get_balance(), 250,
                         'incorrect balance after making payment')
コード例 #12
0
def main():
    cc = CreditCard()

    cc.name = input("Name: ")
    cc.number = input("Number: ")
    
    print("Mailing Address:")
    cc.mailing_address.street = input("Street: ")
    cc.mailing_address.city = input("City: ")
    cc.mailing_address.state = input("State: ")
    cc.mailing_address.zip = input("Zip: ")
    
    print("Billing Address:")
    cc.billing_address.street = input("Street: ")
    cc.billing_address.city = input("City: ")
    cc.billing_address.state = input("State: ")
    cc.billing_address.zip = input("Zip: ")

    cc.display()
コード例 #13
0
ファイル: main.py プロジェクト: silvaadriel/python-project
def new_credit_card():
    print('\n\t==== New Credit Card ====')
    print('\t1 - New client credit card')
    print('\t2 - New registered client credit card')
    print('\t0 - Return')
    choice = str(input('Option: '))

    if choice == '1':
        client = new_client()
        income = float(input("Enter the clients's income: "))
        credit_card_number = str(input('Enter the credit card number: '))
        password = str(input('Enter the password: '******'Your credit limit is {}'.format(new_credit.get_credit_limit()))
        card.set_credit_card(new_credit)
        input("Press the <ENTER> key to continue...")
    elif choice == '2':
        print('\n\t==== Find the registered Client ====')
        cpf = str(input('Cpf: '))
        client = find_client(cpf)
        if client is None:
            print('Client does not exist')
            input("Press the <ENTER> key to continue...")
        else:
            print('Client: {}'.format(client.get_name()))
            income = float(input("Enter the clients's income: "))
            credit_card_number = str(input('Enter the credit card number: '))
            password = str(input('Enter the password: '******'Your credit limit is {}'.format(new_credit.get_credit_limit()))
            card.set_credit_card(new_credit)
            input("Press the <ENTER> key to continue...")
    elif choice == '0':
        return
    else:
        print('This option does not exist')
        input("Press the <ENTER> key to continue...")
コード例 #14
0
from credit_card import CreditCard

cc = CreditCard('John Doe', '1st Bank', '5391 0375 9387 5309', 1000)
print(cc.get_customer())
コード例 #15
0
 def setUp(self):
   self.credit_card = CreditCard('1111222233334444', '14/03/18', 1000.0)
コード例 #16
0
  def test_list_from_person(self):
    with Stub() as person: person.id >> 1

    self.credit_card.person_id = person.id

    CreditCard.list_from_person(person) |should| equal_to([self.credit_card])
コード例 #17
0
 def setUp(self):
     self.cc = CreditCard('John Doe', 'JD Bank', '12345', 1000)
コード例 #18
0
    def test_credit_card_6011053711075799(self):
        cc = CreditCard('6011053711075799')

        self.assertTrue(cc.valid, msg="Discover Card is Valid")
        self.assertEqual(cc.card_type, "DISCOVER", msg="card_type is DISCOVER")
コード例 #19
0
    def test_credit_card_379179199857686(self):
        cc = CreditCard('379179199857686')

        self.assertTrue(cc.valid, msg="AMEX is Valid")
        self.assertEqual(cc.card_type, "AMEX", msg="card_type is AMEX")
コード例 #20
0
    def test_credit_card_4929896355493470(self):
        cc = CreditCard('4929896355493470')

        self.assertTrue(cc.valid, msg="Visa Card is Valid")
        self.assertEqual(cc.card_type, "VISA", msg="card_type is VISA")
コード例 #21
0
ファイル: factory.py プロジェクト: GusW/python_main
    def create_new_credit_card(cls, valid=True, date_benchmark=date.today()):
        targetDate = (date_benchmark +
                      timedelta(days=730) if valid else date_benchmark -
                      timedelta(days=30))

        return CreditCard(expiration_date=targetDate)
コード例 #22
0
#         super().__init__(name)
#         self.side = side

#     def area(self):
#         return self.side * self.side

# class Rectangle(Shape):
#     def __init__(self, name, x, y):
#         super().__init__(name)
#         self.x = x
#         self.y = y

#     def area(self):
#         return self.x * self.y

# if __name__ == "__main__":
#     square = Square("square", 6)
#     print(f"The area of {square.name} is {square.area()}")

#     rectangle = Rectangle("rectangle", 5, 3)
#     print(f"The area of {rectangle.name} is {rectangle.area()}")

from cod import COD
from credit_card import CreditCard

if __name__ == "__main__":
    cod = COD(1000)
    cod.make_payment()

    cc = CreditCard(1000)
    cc.make_payment()