def test_inspect_all_transactions(database, mock_message): character_hash = User.create_user(2, 2, "Test user", database) character_hash_2 = User.create_user(3, 3, "Test user 2", database) client = BankingClientFactory(database).create_client(mock_message) assert client.inspect_all_transactions() == NO_TRANSACTIONS_FOUND assert client.inspect_all_transactions( character_hash_2) == NO_TRANSACTIONS_FOUND half_amount = DEFAULT_FINANCES / 2 sender_chat_id, reciever_chat_id, message = client.create_transaction( f"/send {character_hash_2} {half_amount}") client = BankingClientFactory(database).create_client(mock_message) assert client.inspect_all_transactions() != NO_TRANSACTIONS_FOUND assert client.inspect_all_transactions( character_hash_2) != NO_TRANSACTIONS_FOUND
def test_create_transaction(database, mock_message): character_hash = User.create_user(2, 2, "Test user", database) character_hash_2 = User.create_user(3, 3, "Test user 2", database) client = BankingClientFactory(database).create_client(mock_message) double_amount = DEFAULT_FINANCES * 2 half_amount = DEFAULT_FINANCES / 2 user2 = client.get_user_by_user_hash(character_hash_2) user1 = client.get_user_by_user_hash(character_hash) assert user2.finances == DEFAULT_FINANCES assert user1.finances == DEFAULT_FINANCES with pytest.raises(TransactionError): client.create_transaction(f"/send {character_hash_2} {double_amount}") with pytest.raises(TransactionError): client.create_transaction(f"/send {character_hash} {half_amount}") with pytest.raises(TransactionError): client.create_transaction(f"/send {character_hash_2} notanumber") with pytest.raises(TransactionError): client.create_transaction(f"/send {character_hash_2} 0") with pytest.raises(UserError): client.create_transaction(f"/send 1234567890 {half_amount}") sender_chat_id, reciever_chat_id, message = client.create_transaction( f"/send {character_hash_2} {half_amount}") user2 = client.get_user_by_user_hash(character_hash_2) user1 = client.get_user_by_user_hash(character_hash) assert user2.finances == DEFAULT_FINANCES + half_amount assert user1.finances == DEFAULT_FINANCES - half_amount assert sender_chat_id == user1.chat_id assert reciever_chat_id == user2.chat_id