Fixed test_balance_and_eth_rate to verify USD balance instead of eth rate

This commit is contained in:
Serhy 2017-12-27 20:03:57 +02:00 committed by Anton Danchenko
parent 9f15a2db71
commit 1c14845bbc
2 changed files with 8 additions and 8 deletions

View File

@ -118,7 +118,7 @@ class TestWallet(SingleDeviceTestCase):
transaction_hash=transaction_hash) transaction_hash=transaction_hash)
@pytest.mark.wallet @pytest.mark.wallet
def test_balance_and_eth_rate(self): def test_eth_and_currency_balance(self):
errors = list() errors = list()
home = HomeView(self.driver) home = HomeView(self.driver)
recover_access(home, recover_access(home,
@ -128,10 +128,10 @@ class TestWallet(SingleDeviceTestCase):
chats = home.get_chats() chats = home.get_chats()
address = transaction_users_wallet['A_USER']['address'] address = transaction_users_wallet['A_USER']['address']
balance = get_balance(address) / 1000000000000000000 balance = get_balance(address) / 1000000000000000000
eth_rate = get_ethereum_price_in_usd()
wallet = chats.wallet_button.click() wallet = chats.wallet_button.click()
eth_rate = get_ethereum_price_in_usd()
wallet_balance = wallet.get_eth_value() wallet_balance = wallet.get_eth_value()
if wallet_balance != balance: if wallet_balance != balance:
errors.append('Balance %s is not equal to the expected %s' % (wallet_balance, balance)) errors.append('Balance %s is not equal to the expected %s' % (wallet_balance, balance))
wallet.verify_eth_rate(eth_rate, errors) wallet.verify_currency_balance(eth_rate, errors)
assert not errors, 'errors occurred:\n{}'.format('\n'.join(errors)) assert not errors, 'errors occurred:\n{}'.format('\n'.join(errors))

View File

@ -89,10 +89,10 @@ class WalletViewObject(BaseViewObject):
def get_eth_value(self): def get_eth_value(self):
return float(self.eth_asset.text) return float(self.eth_asset.text)
def verify_eth_rate(self, expected_rate: int, errors: list): def verify_currency_balance(self, expected_rate: int, errors: list):
usd = self.get_usd_total_value() usd = self.get_usd_total_value()
eth = self.get_eth_value() eth = self.get_eth_value()
current_rate = usd / eth expected_usd = round(eth * expected_rate, 2)
if round(current_rate, 2) != expected_rate: if expected_usd != usd:
errors.append('Current ETH rate %s is not equal to the expected %s' % (current_rate, expected_rate)) errors.append('Current USD balance %s is not equal to the expected %s' % (usd, expected_usd))
logging.info('Current ETH rate %s is ok' % current_rate) logging.info('Current USD balance %s is ok' % usd)