Last active
September 2, 2024 15:36
-
-
Save dmytrostriletskyi/906b2f577ffefe4d387e8daa412efa0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestAccountService: | |
def test_transfer_money_with_insufficient_balance(self, enable_in_app_notifications, mock): | |
mock_send_in_app_notification = mock('app.notifications.in_app.send') | |
mock_send_email = mock('app.email.send') | |
receiver_account = AccountFactory() | |
sender_account = AccountFactory(balance=0) | |
with database.managed_session() as session: | |
session.add_all([receiver_account, sender_account]) | |
enable_in_app_notifications(account=sender_account) | |
AccountService.transfer_money(from=sender_account, to=receiver_account, amount=100) | |
assert not sender_account.transfers | |
assert not receiver_account.transfers | |
assert Proposal.get_last(account=sender_account, type=ProposalType.INCREASE_CREDIT_LIMIT) | |
mock_send_in_app_notification.assert_called_with( | |
account_id=sender_account.id, | |
type=InAppNotificationType.INSUFFICIENT_BALANCE, | |
expired_at=None, | |
) | |
mock_send_email.assert_called_with( | |
account_id=sender_account.id, | |
type=EmailType.INSUFFICIENT_BALANCE, | |
expired_at=None, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment