Add test for get_payments_out()

This commit is contained in:
Michał Sałaban 2017-12-04 07:36:57 +01:00
parent 4e9284c064
commit bb6c0df230

View file

@ -1,3 +1,4 @@
from datetime import datetime
from decimal import Decimal
import unittest
from unittest.mock import patch, Mock
@ -192,3 +193,114 @@ class SubaddrWalletTestCase(unittest.TestCase):
for payment in pay_in:
self.assertIsInstance(payment['amount'], Decimal)
self.assertIsInstance(payment['fee'], Decimal)
@patch('monero.backends.jsonrpc.requests.post')
def test_get_payments_out(self, mock_post):
mock_post.return_value.status_code = 200
mock_post.return_value.json.return_value = {'id': 0,
'jsonrpc': '2.0',
'result': {'subaddress_accounts': [{'account_index': 0,
'balance': 224916129245183,
'base_address': '9vgV48wWAPTWik5QSUSoGYicdvvsbSNHrT9Arsx1XBTz6VrWPSgfmnUKSPZDMyX4Ms8R9TkhB4uFqK9s5LUBbV6YQN2Q9ag',
'label': 'Primary account',
'unlocked_balance': 224916129245183},
{'account_index': 1,
'balance': 3981420960933,
'base_address': 'BaCBwYSK9BGSuKxb2msXEj4mmpvZYJexYHfqx7kNPDrXDePVXSfoofxGquhXxpA4uxawcnVnouusMDgP74CACa7e9siimpj',
'label': 'Untitled account',
'unlocked_balance': 3981420960933},
{'account_index': 2,
'balance': 7256159239955,
'base_address': 'BgCseuY3jFJAZS7kt9mrNg7fEG3bo5BV91CTyKbYu9GFiU6hUZhvdNWCTUdQNPNcA4PyFApsFr3EsQDEDfT3tQSY1mVZeP2',
'label': 'Untitled account',
'unlocked_balance': 7256159239955}],
'total_balance': 236153709446071,
'total_unlocked_balance': 236153709446071}}
self.wallet = Wallet(JSONRPC())
mock_post.return_value.status_code = 200
mock_post.return_value.json.return_value = {'id': 0,
'jsonrpc': '2.0',
'result': {'out': [{'amount': 484257334653,
'destinations': [{'address': 'BeUtm39sgTWfehPwwdrWWCAyUVfRQ512TTU5R1cm4SVmPVFxcqDz2zo5YGiyHtdav2RnDFdNvVnTANgsKtYTqo7kUCPvkqK',
'amount': 484257334653}],
'double_spend_seen': False,
'fee': 19254480000,
'height': 1051266,
'note': '',
'payment_id': '0000000000000000',
'subaddr_index': {'major': 2, 'minor': 0},
'timestamp': 1512095241,
'txid': 'eadca0f956a2a60cb3497a7dff1bd80153140a111d2f7db257a264bd9b76f0b3',
'type': 'out',
'unlock_time': 0},
{'amount': 791221885761,
'destinations': [{'address': 'Bd2RQrySgNaBghRZimDu54iTeJPQFZqPKc36Mb8gWiiU3ripWBv7zZZYkGDBCd5uC1efzh88V3PhyeRhMEYiMSLPN2KLFAj',
'amount': 791221885761}],
'double_spend_seen': False,
'fee': 19304320000,
'height': 1049917,
'note': '',
'payment_id': '0000000000000000',
'subaddr_index': {'major': 2, 'minor': 0},
'timestamp': 1511922110,
'txid': '5486ae9e6867ceb6e5aa478b32cba5c11d28e6d905c8479565c78e3933163ab6',
'type': 'out',
'unlock_time': 0},
{'amount': 98047029154,
'destinations': [{'address': '9xJAXRqfKJVgFcqAQPk6bThkjAhAdJ18tSTcpfpiSD634t74RqhzC3kAtHMNbScqkJCDhnvv5iCeuATuNS3r5y51RktPsoZ',
'amount': 98047029154}],
'double_spend_seen': False,
'fee': 19253920000,
'height': 1051282,
'note': '',
'payment_id': '0000000000000000',
'subaddr_index': {'major': 2, 'minor': 0},
'timestamp': 1512098498,
'txid': '9591c8f6832cc3b7908c2447b2feef58c44e7774a5c05cea617ad2f3b3866c18',
'type': 'out',
'unlock_time': 0},
{'amount': 536269959084,
'destinations': [{'address': 'Bfiu2Zm5uoV8RkjGJVWtp2Wkzct15mdKcdM6P6CZsLkPfttjPqvXWR2GkdkG2ai91KNvyro8zKygygMcTf6feyUA8nJmyNT',
'amount': 536269959084}],
'double_spend_seen': False,
'fee': 19303200000,
'height': 1049947,
'note': '',
'payment_id': '0000000000000000',
'subaddr_index': {'major': 2, 'minor': 0},
'timestamp': 1511926250,
'txid': 'af669b99162d9b514a0e8d3bd1d905e3b8778e6fcb88d172e5e049e909c4cc87',
'type': 'out',
'unlock_time': 0},
{'amount': 179693868346,
'destinations': [{'address': '9wFuzNoQDck1pnS9ZhG47kDdLD1BUszSbWpGfWcSRy9m6Npq9NoHWd141KvGag8hu2gajEwzRXJ4iJwmxruv9ofc2CwnYCE',
'amount': 179693868346}],
'double_spend_seen': False,
'fee': 17927000000,
'height': 1049870,
'note': '',
'payment_id': '0000000000000000',
'subaddr_index': {'major': 2, 'minor': 0},
'timestamp': 1511914391,
'txid': '2fa2de7fbf009093c5319d0421d3e8c684b8351a066c48d51369aedbbfd1d9af',
'type': 'out',
'unlock_time': 0},
{'amount': 540005123047,
'destinations': [{'address': 'BYo9Bf1FXxBdM655QkQsxs25HZ78EehDmJWZfLAts8LFcym4k8LbEywJcWnoCBHVXQb5ZJ6JXrF2MFtNrVnswGXsAxWNBgh',
'amount': 540005123047}],
'double_spend_seen': False,
'fee': 19302640000,
'height': 1049963,
'note': '',
'payment_id': '0000000000000000',
'subaddr_index': {'major': 2, 'minor': 0},
'timestamp': 1511928624,
'txid': '7e3db6c59c02d870f18b37a37cfc5857eeb5412df4ea00bb1971f3095f72b0d8',
'type': 'out',
'unlock_time': 0}]}}
pay_out = self.wallet.get_payments_out()
self.assertEqual(len(list(pay_out)), 6)
for payment in pay_out:
self.assertIsInstance(payment['amount'], Decimal)
self.assertIsInstance(payment['fee'], Decimal)
self.assertIsInstance(payment['timestamp'], datetime)