Пример #1
0
 def test_check_balance_invalid_command(self):
     bank_iface = BankConnection(self.config)
     card_id = '111      '
     res = bank_iface.check_balance(card_id)
     self.assertTrue(res[:5] == 'ERROR')
     self.assertTrue(
         res[6:] == 'check_balance command usage: balance <card_id>')
Пример #2
0
    def test_overdraw_atm(self):
        bank_iface = BankConnection(self.config)
        account_name = 'martha'
        amount = '400'
        card_id = self.admin_iface.create_account(account_name, amount)
        self.assertTrue(card_id)

        bal = self.admin_iface.check_balance('martha')
        self.assertTrue(bal == 400)

        card_id_inv = self.admin_iface.create_account(account_name, amount)
        self.assertTrue(card_id_inv == False)

        res = bank_iface.check_balance(card_id)
        self.assertTrue(int(res[5:]) == 400)

        atm_id = self.admin_iface.create_atm()
        self.assertTrue(res)

        bal = self.admin_iface.check_balance('martha')
        self.assertTrue(bal == 400)

        res = bank_iface.withdraw(atm_id, card_id, 400)
        self.assertTrue(res[:5] == 'ERROR')
        print res
        bal = self.admin_iface.check_balance('martha')
        self.assertTrue(bal == 400)
Пример #3
0
    def test_all(self):
        bank_iface = BankConnection(self.config)
        account_name = 'marsha'
        amount = '57'
        card_id = self.admin_iface.create_account(account_name, amount)
        self.assertTrue(card_id)

        bal = self.admin_iface.check_balance('marsha')
        self.assertTrue(bal == 57)

        card_id_inv = self.admin_iface.create_account(account_name, amount)
        self.assertTrue(card_id_inv == False)

        res = bank_iface.check_balance(card_id)
        self.assertTrue(int(res[5:]) == 57)

        atm_id = self.admin_iface.create_atm()
        self.assertTrue(res)

        bal = self.admin_iface.check_balance('marsha')
        self.assertTrue(bal == 57)

        res = bank_iface.withdraw(atm_id, card_id, 57)
        self.assertTrue(res[:4] == 'OKAY')

        bal = self.admin_iface.check_balance('marsha')
        self.assertTrue(bal == 0)

        self.admin_iface.update_balance('marsha', 15)
        bal = self.admin_iface.check_balance('marsha')
        self.assertTrue(bal == 15)
Пример #4
0
 def test_check_balance_invalid_card_id(self):
     bank_iface = BankConnection(self.config)
     card_id = str(uuid.UUID('{53000000-0000-0000-0000-000000000000}'))
     res = bank_iface.check_balance(card_id)
     print res
     self.assertTrue(res[:5] == 'ERROR')
     self.assertTrue(res[6:] == 'could not lookup account \'' + card_id +
                     '\'')
Пример #5
0
 def test_check_balance_valid(self):
     bank_iface = BankConnection(self.config)
     card_id = str(uuid.UUID('{50000000-0000-0000-0000-000000000000}'))
     res = bank_iface.check_balance(card_id)
     print 'output'
     print res
     print self.config
     print 'output'
     self.assertTrue(res[:4] == 'OKAY')
     self.assertTrue(int(res[5:]) == 10)