mirror of
https://git.wownero.com/lza_menace/wownero-python.git
synced 2024-08-15 03:25:25 +00:00
Factor the get_accounts() mock response, make imports work in Python 2
This commit is contained in:
parent
bb6c0df230
commit
864b8f237a
1 changed files with 28 additions and 77 deletions
105
tests/wallet.py
105
tests/wallet.py
|
@ -1,34 +1,39 @@
|
|||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
import unittest
|
||||
from unittest.mock import patch, Mock
|
||||
try:
|
||||
from unittest.mock import patch, Mock
|
||||
except ImportError:
|
||||
from mock import patch, Mock
|
||||
|
||||
from monero.wallet import Wallet
|
||||
from monero.backends.jsonrpc import JSONRPC
|
||||
|
||||
class SubaddrWalletTestCase(unittest.TestCase):
|
||||
get_accounts_result = {'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}}
|
||||
|
||||
@patch('monero.backends.jsonrpc.requests.post')
|
||||
def test_get_balance(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}}
|
||||
mock_post.return_value.json.return_value = self.get_accounts_result
|
||||
self.wallet = Wallet(JSONRPC())
|
||||
mock_post.return_value.json.return_value = {'id': 0,
|
||||
'jsonrpc': '2.0',
|
||||
|
@ -66,25 +71,7 @@ class SubaddrWalletTestCase(unittest.TestCase):
|
|||
@patch('monero.backends.jsonrpc.requests.post')
|
||||
def test_get_address(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}}
|
||||
mock_post.return_value.json.return_value = self.get_accounts_result
|
||||
self.wallet = Wallet(JSONRPC())
|
||||
mock_post.return_value.json.return_value = {'id': 0,
|
||||
'jsonrpc': '2.0',
|
||||
|
@ -132,25 +119,7 @@ class SubaddrWalletTestCase(unittest.TestCase):
|
|||
@patch('monero.backends.jsonrpc.requests.post')
|
||||
def test_get_payments_in(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}}
|
||||
mock_post.return_value.json.return_value = self.get_accounts_result
|
||||
self.wallet = Wallet(JSONRPC())
|
||||
mock_post.return_value.status_code = 200
|
||||
mock_post.return_value.json.return_value ={'id': 0,
|
||||
|
@ -197,25 +166,7 @@ class SubaddrWalletTestCase(unittest.TestCase):
|
|||
@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}}
|
||||
mock_post.return_value.json.return_value = self.get_accounts_result
|
||||
self.wallet = Wallet(JSONRPC())
|
||||
mock_post.return_value.status_code = 200
|
||||
mock_post.return_value.json.return_value = {'id': 0,
|
||||
|
|
Loading…
Reference in a new issue