Skip to content

Commit

Permalink
Fix utilityPayment tests
Browse files Browse the repository at this point in the history
  • Loading branch information
luistarkbank committed Feb 18, 2025
1 parent c9f7db7 commit f0ebe5c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 21 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Given a version number MAJOR.MINOR.PATCH, increment:


## [Unreleased]
### Fixed
- pytest tests

## [2.26.0] - 2024-07-01
### Added
Expand Down
29 changes: 17 additions & 12 deletions tests/sdk/test_corporate_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,24 @@

starkbank.user = exampleProject

class TestCorporateCardPost(TestCase):

def test_success(self):

holder = starkbank.corporateholder.create(generateExampleHoldersJson(n=1), expand=["rules"])[0]
card = starkbank.corporatecard.create(card=generateExampleCardJson(holder=holder), expand=["securityCode"])
self.assertNotEqual(str(card.security_code), "***")

card_id = card.id
card = starkbank.corporatecard.update(card_id, display_name="Updated Name", tags=["pytest"])
self.assertEqual("Updated Name", card.display_name)


class TestCorporateCardQuery(TestCase):

def test_success(self):
cards = starkbank.corporatecard.query(
limit=10,
limit=100,
after=date.today() - timedelta(days=100),
before=date.today()
)
Expand Down Expand Up @@ -47,20 +59,13 @@ def test_success(self):
self.assertEqual(card.id, str(card.id))


class TestCorporateCardPostAndDelete(TestCase):
class TestCorporateCardDelete(TestCase):

def test_success(self):

holder = starkbank.corporateholder.create(generateExampleHoldersJson(n=1), expand=["rules"])[0]
card = starkbank.corporatecard.create(card=generateExampleCardJson(holder=holder), expand=["securityCode"])
self.assertNotEqual(str(card.security_code), "***")

card_id = card.id
card = starkbank.corporatecard.update(card_id, display_name="Updated Name")
self.assertEqual("Updated Name", card.display_name)

card = starkbank.corporatecard.cancel(id=card_id)
self.assertEqual("canceled", card.status)
cards = starkbank.corporatecard.query(limit=1, tags=["pytest"])
for card in cards:
self.assertEqual("canceled", starkbank.corporatecard.cancel(id=card.id).status)


class TestCorporateCardUpdate(TestCase):
Expand Down
18 changes: 10 additions & 8 deletions tests/sdk/test_deposit.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,18 @@ def test_success(self):
class TestDepositInfoPatch(TestCase):

def test_success_amount(self):
deposits = starkbank.deposit.query(status="created", limit=1)
deposits = starkbank.deposit.query(status="created", limit=20)
deposit_amount = 0
for deposit in deposits:
self.assertIsNotNone(deposit.id)
updated_deposit = starkbank.deposit.update(
deposit.id,
amount=deposit_amount,
)
print(updated_deposit)
self.assertEqual(updated_deposit.amount, deposit_amount)
if deposit.type != "ted":
self.assertIsNotNone(deposit.id)
updated_deposit = starkbank.deposit.update(
deposit.id,
amount=deposit_amount,
)
print(updated_deposit)
self.assertEqual(updated_deposit.amount, deposit_amount)
break


if __name__ == '__main__':
Expand Down
8 changes: 7 additions & 1 deletion tests/sdk/test_utility_payment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import starkbank
from datetime import date, timedelta
from unittest import TestCase, main
from tests.utils.user import exampleProject
from tests.utils.utilityPayment import generateExampleUtilityPaymentsJson
Expand Down Expand Up @@ -52,7 +53,12 @@ def test_success(self):
class TestUtilityPaymentDelete(TestCase):

def test_success(self):
payments = generateExampleUtilityPaymentsJson(n=1, next_day=True)
payments = [starkbank.UtilityPayment(
description="e6cba87f05fd73aa49306864ab0098f58e7c43f8a9403475a9f10ac605b6ed87",
scheduled=str(date.today() + timedelta(days=1)),
tags=["utility", "payment"],
line="83640000001 1 08740138007 0 61053026111 0 08067159411 9"
)]
payments = starkbank.utilitypayment.create(payments)
starkbank.utilitypayment.delete(payments[0].id)

Expand Down

0 comments on commit f0ebe5c

Please sign in to comment.