wallet withdraw by category uuid and check its and other wallets desired balance
This commit is contained in:
parent
bcc07f75d4
commit
e4093ee4de
1 changed files with 54 additions and 0 deletions
|
|
@ -327,6 +327,60 @@ class ApplicationApiFlowsTests(APITestCase):
|
|||
self.assertContains(response, 'balance')
|
||||
self.assertEqual(response.json()['balance'], 200)
|
||||
|
||||
def test_withdraw_flow_category_success(self):
|
||||
auth = self._create_authorization_header(self.payer_access_token.token)
|
||||
|
||||
# Checking wallets initials values(application balance = 300 and payee balance = zero)
|
||||
kwargs_category_uuid = {
|
||||
'category_uuid': self.wallet_category1_uuid
|
||||
}
|
||||
response = self.client.get(reverse('wallet:application_wallet_balance_api', kwargs=kwargs_category_uuid), HTTP_AUTHORIZATION=auth)
|
||||
self.assertContains(response, 'balance')
|
||||
self.assertEqual(response.json()['balance'], 300)
|
||||
kwargs_category_uuid_payer_uuid = {
|
||||
'category_uuid': self.wallet_category1_uuid,
|
||||
'uuid': self.payer_uuid,
|
||||
}
|
||||
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=kwargs_category_uuid_payer_uuid), HTTP_AUTHORIZATION=auth)
|
||||
self.assertContains(response, 'balance')
|
||||
self.assertEqual(response.json()['balance'], 300)
|
||||
|
||||
# Deposit process
|
||||
data = {
|
||||
'amount': 100,
|
||||
'payer_id': self.payer_uuid,
|
||||
'payer_type': TypeChoices.USER
|
||||
}
|
||||
response = self.client.post(reverse('wallet:application_withdraw_submit_api', kwargs=kwargs_category_uuid), data=data, HTTP_AUTHORIZATION=auth)
|
||||
self.assertEqual(response.status_code, 201)
|
||||
json_response = response.json()
|
||||
|
||||
kwargs_category_uuid_transaction_uuid = {
|
||||
'category_uuid': self.wallet_category1_uuid,
|
||||
'uuid': json_response['uuid'],
|
||||
}
|
||||
response = self.client.get(reverse('wallet:application_withdraw_verify_api', kwargs=kwargs_category_uuid_transaction_uuid), HTTP_AUTHORIZATION=auth)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.json()['state'], 5)
|
||||
|
||||
# Desired results
|
||||
response = self.client.get(reverse('wallet:application_wallet_balance_api', kwargs=kwargs_category_uuid), HTTP_AUTHORIZATION=auth)
|
||||
self.assertContains(response, 'balance')
|
||||
self.assertEqual(response.json()['balance'], 400)
|
||||
|
||||
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=kwargs_category_uuid_payer_uuid), HTTP_AUTHORIZATION=auth)
|
||||
self.assertContains(response, 'balance')
|
||||
self.assertEqual(response.json()['balance'], 200)
|
||||
|
||||
kwargs_category_uuid_payer_uuid = {
|
||||
'category_uuid': self.wallet_category2_uuid,
|
||||
'uuid': self.payer_uuid,
|
||||
}
|
||||
|
||||
response = self.client.get(reverse('wallet:application_user_wallet_balance_api', kwargs=kwargs_category_uuid_payer_uuid), HTTP_AUTHORIZATION=auth)
|
||||
self.assertContains(response, 'balance')
|
||||
self.assertEqual(response.json()['balance'], 300)
|
||||
|
||||
def test_withdraw_flow_insufficient_balance(self):
|
||||
auth = self._create_authorization_header(self.payer_access_token.token)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue