fixed an issue with rounded sum in request command, added test 'send funds via request in group chat', added new users for wallet tests

This commit is contained in:
Anton Danchenko 2017-12-07 14:14:45 +01:00
parent 6aed718984
commit f227962a89
4 changed files with 64 additions and 33 deletions

View File

@ -18,6 +18,7 @@ class TestData(object):
self.test_name = None self.test_name = None
self.apk_name = None self.apk_name = None
test_data = TestData()
basic_user = {'password': "newuniquepassword12", basic_user = {'password': "newuniquepassword12",
'passphrase': "tree weekend ceiling awkward universe pyramid glimpse raven pair lounge grant grief", 'passphrase': "tree weekend ceiling awkward universe pyramid glimpse raven pair lounge grant grief",
@ -42,4 +43,23 @@ transaction_users = {
}, },
} }
test_data = TestData()
transaction_users_wallet = dict()
transaction_users_wallet['A_USER'] = dict()
transaction_users_wallet['A_USER']['password'] = "new_unique_password"
transaction_users_wallet['A_USER']['passphrase'] = "kiss catch paper awesome ecology surface " \
"trumpet quit index open stage brave"
transaction_users_wallet['A_USER']['username'] = "Impractical Afraid Watermoccasin"
transaction_users_wallet['A_USER']['address'] = "a409e5faf758a5739f334bae186d8bc11c98ea4d"
transaction_users_wallet['A_USER']['public_key'] = "0x04630e0acd973ad448c7a54e2345d6bacaaa4de5a0ec938f802a0f503bf144e" \
"80521833be71d4ddfefacfa571a473ebe4542dde102aca4e90d2abe0bb67ee2f99b"
transaction_users_wallet['B_USER'] = dict()
transaction_users_wallet['B_USER']['password'] = "new_unique_password"
transaction_users_wallet['B_USER']['passphrase'] = "twenty engine fitness clay faculty supreme " \
"garbage armor broccoli agree end sad"
transaction_users_wallet['B_USER']['username'] = "Muffled Purple Milksnake"
transaction_users_wallet['B_USER']['address'] = "5261ceba31e3a7204b498b2dd20220a6057738d1"
transaction_users_wallet['B_USER']['public_key'] = "0x04cd70746f3df6cae7b45c32c211bd7e9e95ed5a1ec470db8f3b1f244eed182" \
"1d4a2053d7671802c5f7ce5b81f5fc2016a8109e1bc83f151ceff21f08c0cdcc6e4"

View File

@ -12,6 +12,7 @@ from views.home import HomeView
@pytest.mark.all @pytest.mark.all
class TestMultiplyDevices(MultiplyDeviceTestCase): class TestMultiplyDevices(MultiplyDeviceTestCase):
@pytest.mark.discover @pytest.mark.discover
def test_new_profile_name_and_status_on_discover(self): def test_new_profile_name_and_status_on_discover(self):
device_1, device_2 = HomeView(self.driver_1), HomeView(self.driver_2) device_1, device_2 = HomeView(self.driver_1), HomeView(self.driver_2)
@ -173,24 +174,23 @@ class TestMultiplyDevices(MultiplyDeviceTestCase):
if message_text.is_element_present(20): if message_text.is_element_present(20):
pytest.fail('Message is shown for the user which has been removed from the GroupChat', False) pytest.fail('Message is shown for the user which has been removed from the GroupChat', False)
@pytest.mark.chat @pytest.mark.transaction
def test_send_funds_via_request_in_one_to_one_chat(self): @pytest.mark.parametrize("test, recipient, sender", [('group_chat', transaction_users['A_USER'],
recipient = transaction_users['A_USER'] transaction_users['B_USER']),
sender = transaction_users['B_USER'] ('one_to_one_chat', transaction_users['B_USER'],
transaction_users['A_USER'])])
def test_send_funds_via_request(self, test, recipient, sender):
device_1, device_2 = HomeView(self.driver_1), HomeView(self.driver_2) device_1, device_2 = HomeView(self.driver_1), HomeView(self.driver_2)
recover_access(device_1, recover_access(device_1,
passphrase=recipient['passphrase'], passphrase=recipient['passphrase'],
password=recipient['password'], password=recipient['password'],
username=recipient['username']) username=recipient['username'])
chats_d1 = device_1.get_chats() chats_d1 = device_1.get_chats()
recover_access(device_2, recover_access(device_2,
passphrase=sender['passphrase'], passphrase=sender['passphrase'],
password=sender['password'], password=sender['password'],
username=sender['username']) username=sender['username'])
chats_d2 = device_2.get_chats() chats_d2 = device_2.get_chats()
try: try:
chats_d1.element_by_text_part(sender['username'][:25], 'button').click() chats_d1.element_by_text_part(sender['username'][:25], 'button').click()
except NoSuchElementException: except NoSuchElementException:
@ -199,24 +199,39 @@ class TestMultiplyDevices(MultiplyDeviceTestCase):
chats_d1.public_key_edit_box.send_keys(sender['public_key']) chats_d1.public_key_edit_box.send_keys(sender['public_key'])
chats_d1.confirm() chats_d1.confirm()
chats_d1.confirm_public_key_button.click() chats_d1.confirm_public_key_button.click()
if test == 'group_chat':
for _ in range(2):
chats_d1.back_button.click()
chats_d1.new_group_chat_button.click()
sender_username = chats_d1.element_by_text(sender['username'], 'button')
sender_username.scroll_to_element()
sender_username.click()
chats_d1.next_button.click()
chat_name = 'transaction_group_chat'
chats_d1.name_edit_box.send_keys(chat_name)
chats_d1.save_button.click()
group_chat_d2 = chats_d2.element_by_text(chat_name, 'button')
group_chat_d2.click()
chats_d1.request_funds_button.click() chats_d1.request_funds_button.click()
amount = get_unique_amount() amount = get_unique_amount()
chats_d1.chat_message_input.set_value(amount) if test == 'group_chat':
chats_d1.first_recipient_button.click()
chats_d1.send_as_keyevent(amount)
else:
chats_d1.chat_message_input.set_value(amount)
chats_d1.send_message_button.click() chats_d1.send_message_button.click()
initial_balance_recipient = get_balance(recipient['address']) initial_balance_recipient = get_balance(recipient['address'])
if test == 'group_chat':
chats_d1.find_full_text('from ' + sender['username'], 60)
chats_d2.find_full_text('from ' + sender['username'], 60)
chats_d2.element_by_text_part(recipient['username'][:25], 'button').click() chats_d2.element_by_text_part(recipient['username'][:25], 'button').click()
chats_d2.element_by_text('Requesting %s ETH' % amount, 'button').click() chats_d2.element_by_text_part('Requesting %s ETH' % amount, 'button').click()
chats_d2.send_message_button.click() chats_d2.send_message_button.click()
chats_d2.sign_transaction_button.click() chats_d2.sign_transaction_button.click()
chats_d2.enter_password_input.send_keys(sender['password']) chats_d2.enter_password_input.send_keys(sender['password'])
chats_d2.sign_transaction_button.click() chats_d2.sign_transaction_button.click()
chats_d2.got_it_button.click() chats_d2.got_it_button.click()
verify_balance_is_updated(initial_balance_recipient, recipient['address']) verify_balance_is_updated(initial_balance_recipient, recipient['address'])
chats_d2.verify_amount_is_sent(amount)
chats_d2.back_button.click() chats_d2.back_button.click()
wallet = chats_d2.wallet_button.click() wallet = chats_d2.wallet_button.click()
tr_view = wallet.transactions_button.click() tr_view = wallet.transactions_button.click()

View File

@ -7,7 +7,7 @@ from views.base_view import verify_transaction_in_ropsten
from views.chats import get_unique_amount from views.chats import get_unique_amount
from views.home import HomeView from views.home import HomeView
from tests.preconditions import set_password_as_new_user, recover_access from tests.preconditions import set_password_as_new_user, recover_access
from tests import transaction_users from tests import transaction_users_wallet
@pytest.mark.all @pytest.mark.all
@ -35,14 +35,14 @@ class TestWallet(SingleDeviceTestCase):
def test_send_transaction_from_wallet(self, test, recipient, sender): def test_send_transaction_from_wallet(self, test, recipient, sender):
home = HomeView(self.driver) home = HomeView(self.driver)
recover_access(home, recover_access(home,
transaction_users[sender]['passphrase'], transaction_users_wallet[sender]['passphrase'],
transaction_users[sender]['password'], transaction_users_wallet[sender]['password'],
transaction_users[sender]['username']) transaction_users_wallet[sender]['username'])
chats = home.get_chats() chats = home.get_chats()
chats.wait_for_syncing_complete() chats.wait_for_syncing_complete()
recipient_key = transaction_users[recipient]['public_key'] recipient_key = transaction_users_wallet[recipient]['public_key']
recipient_address = transaction_users[recipient]['address'] recipient_address = transaction_users_wallet[recipient]['address']
initial_balance_recipient = get_balance(recipient_address) initial_balance_recipient = get_balance(recipient_address)
chats.plus_button.click() chats.plus_button.click()
@ -62,7 +62,7 @@ class TestWallet(SingleDeviceTestCase):
wallet.chose_recipient_button.click() wallet.chose_recipient_button.click()
wallet.deny_button.click() wallet.deny_button.click()
wallet.chose_from_contacts_button.click() wallet.chose_from_contacts_button.click()
user_contact = chats.element_by_text(transaction_users[recipient]['username'], 'button') user_contact = chats.element_by_text(transaction_users_wallet[recipient]['username'], 'button')
user_contact.click() user_contact.click()
if test == 'sign_later': if test == 'sign_later':
@ -74,7 +74,7 @@ class TestWallet(SingleDeviceTestCase):
tr_view.sign_button.click() tr_view.sign_button.click()
chats.sign_transaction_button.click() chats.sign_transaction_button.click()
chats.enter_password_input.send_keys(transaction_users[sender]['password']) chats.enter_password_input.send_keys(transaction_users_wallet[sender]['password'])
chats.sign_transaction_button.click() chats.sign_transaction_button.click()
chats.got_it_button.click() chats.got_it_button.click()
verify_balance_is_updated(initial_balance_recipient, recipient_address) verify_balance_is_updated(initial_balance_recipient, recipient_address)
@ -86,18 +86,18 @@ class TestWallet(SingleDeviceTestCase):
transaction = tr_view.transactions_table.find_transaction(amount=amount) transaction = tr_view.transactions_table.find_transaction(amount=amount)
details_view = transaction.click() details_view = transaction.click()
transaction_hash = details_view.get_transaction_hash() transaction_hash = details_view.get_transaction_hash()
verify_transaction_in_ropsten(address=transaction_users[sender]['address'], transaction_hash=transaction_hash) verify_transaction_in_ropsten(address=transaction_users_wallet[sender]['address'], transaction_hash=transaction_hash)
@pytest.mark.wallet @pytest.mark.wallet
def test_balance_and_eth_rate(self): def test_balance_and_eth_rate(self):
errors = list() errors = list()
home = HomeView(self.driver) home = HomeView(self.driver)
recover_access(home, recover_access(home,
passphrase=transaction_users['A_USER']['passphrase'], passphrase=transaction_users_wallet['A_USER']['passphrase'],
password=transaction_users['A_USER']['password'], password=transaction_users_wallet['A_USER']['password'],
username=transaction_users['A_USER']['username']) username=transaction_users_wallet['A_USER']['username'])
chats = home.get_chats() chats = home.get_chats()
address = transaction_users['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() eth_rate = get_ethereum_price_in_usd()
wallet = chats.wallet_button.click() wallet = chats.wallet_button.click()

View File

@ -246,10 +246,6 @@ class ChatsViewObject(BaseViewObject):
except TimeoutException: except TimeoutException:
break break
def verify_amount_is_sent(self, amount):
self.driver.find_element(
BaseElement.Locator.xpath_selector("//*[@text='/send']/../../*[@text='%s']/../*[@text='ETH']" % amount))
def get_unique_amount(): def get_unique_amount():
return '0.00%s' % datetime.now().strftime('%-m%-d%-H%-M%-S').strip('0') return '0.0%s' % datetime.now().strftime('%-m%-d%-H%-M%-S').strip('0')