def test_account_update(self): """ Test to verify the update of existing account details """ bankCustomer = BankCustomer(first_name="Manish", last_name="Jain", birth_date="1993-10-28", address="33,Rue du president,Ixelles") bankCustomer.save() bankAccount = BankAccount(customer_id=bankCustomer, acc_type='Credit_Card', acc_balance=40.5) bankAccount.save() data = { 'customer_id': '1', 'acc_type': 'Credit_Card', 'acc_balance': '50', } response = self.client.put('/account/' + str(bankAccount.acc_number), data, format='json') self.assertEqual(200, response.status_code) self.assertEqual(data['customer_id'], str(response.data['customer_id'])) self.assertEqual(data['acc_type'], response.data['acc_type']) self.assertEqual(float(data['acc_balance']), response.data['acc_balance'])
def test_create_credit_transfer_with_valid_data(self): """ Test to verify create transfer with valid data """ bankCustomer = BankCustomer(first_name="Manish", last_name="Jain", birth_date="1993-10-28", address="33,Rue du president,Ixelles") bankCustomer.save() bankAccount = BankAccount(customer_id=bankCustomer, acc_type='Credit_Card', acc_balance=40.5) bankAccount.save() data = { 'originator_customer_id': bankCustomer.id, 'originator_acc_number': bankAccount.acc_number, 'beneficary_acc_number': 500, 'transfer_amount': 20.0 } response = self.client.post('/payment/create', data, format='json') self.assertEqual(201, response.status_code) self.assertEqual(data['originator_customer_id'], response.data['originator_customer_id']) self.assertEqual(data['originator_acc_number'], response.data['originator_acc_number']) self.assertEqual(data['transfer_amount'], response.data['transfer_amount'])
def test_account_get(self): ''' Test to verify that a get call for all account list return the success status ''' bankCustomer = BankCustomer(first_name="Manish", last_name="Jain", birth_date="1993-10-28", address="33,Rue du president,Ixelles") bankCustomer.save() bankAccount = BankAccount(customer_id=bankCustomer, acc_type='Credit_Card', acc_balance=40.5) bankAccount.save() response = self.client.get('/account/' + str(bankAccount.acc_number)) self.assertEqual(200, response.status_code)
def test_account_delete(self): """ Test to verify the delete of existing account data """ bankCustomer = BankCustomer(first_name="Manish", last_name="Jain", birth_date="1993-10-28", address="33,Rue du president,Ixelles") bankCustomer.save() bankAccount = BankAccount(customer_id=bankCustomer, acc_type='Credit_Card', acc_balance=40.5) bankAccount.save() response = self.client.delete('/account/' + str(bankAccount.acc_number)) self.assertEqual(204, response.status_code)
def test_create_account(self): """ Test to verify that a post call with valid account data """ bankCustomer = BankCustomer(first_name="Manish", last_name="Jain", birth_date="1993-10-28", address="33,Rue du president,Ixelles") bankCustomer.save() data = { 'customer_id': '1', 'acc_type': 'Credit_Card', 'acc_balance': '50', } response = self.client.post('/account/create', data, format='json') self.assertEqual(201, response.status_code) self.assertEqual(data['customer_id'], str(response.data['customer_id'])) self.assertEqual(data['acc_type'], response.data['acc_type']) self.assertEqual(float(data['acc_balance']), response.data['acc_balance'])
def test_delete_credit_transfer(self): """ Test to verify delete of already exist create transfer """ bankCustomer = BankCustomer(first_name="Manish", last_name="Jain", birth_date="1993-10-28", address="33,Rue du president,Ixelles") bankCustomer.save() bankAccount = BankAccount(customer_id=bankCustomer, acc_type='Credit_Card', acc_balance=40.5) bankAccount.save() creditTranafer = CreditTransfer( originator_customer_id=bankCustomer.id, originator_acc_number=bankAccount.acc_number, beneficary_acc_number=500, transfer_amount='40') creditTranafer.save() response = self.client.delete('/payment/' + str(creditTranafer.id)) self.assertEqual(204, response.status_code)
def test__credit_transfer_with_more_transfer_amount(self): """ Test to verify that a post call fails to create transfer with more amount than available balance. this is a negative test case """ bankCustomer = BankCustomer(first_name="Manish", last_name="Jain", birth_date="1993-10-28", address="33,Rue du president,Ixelles") bankCustomer.save() bankAccount = BankAccount(customer_id=bankCustomer, acc_type='Credit_Card', acc_balance=40.5) bankAccount.save() data = { 'originator_customer_id': bankCustomer.id, 'originator_acc_number': bankAccount.acc_number, 'beneficary_acc_number': 500, 'transfer_amount': 50.0 } response = self.client.post('/payment/create', data, format='json') self.assertEqual(400, response.status_code)