Added populate_test_data method
This commit is contained in:
parent
1e683e6eab
commit
4a02a33226
|
@ -29,15 +29,6 @@ def cleanup(files=_files):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def populate_test_data():
|
|
||||||
"""Set temp data in tmp directory"""
|
|
||||||
for file_name in tmp_db_file:
|
|
||||||
old_source_file = os.path.join(
|
|
||||||
os.path.abspath(os.path.dirname(__file__)), 'sampleData', file_name)
|
|
||||||
new_destination_file = os.path.join(os.environ['BITMESSAGE_HOME'], file_name)
|
|
||||||
shutil.copyfile(old_source_file, new_destination_file)
|
|
||||||
|
|
||||||
|
|
||||||
class TeleniumTestProcess(TeleniumTestCase):
|
class TeleniumTestProcess(TeleniumTestCase):
|
||||||
"""Setting Screen Functionality Testing"""
|
"""Setting Screen Functionality Testing"""
|
||||||
cmd_entrypoint = [os.path.join(os.path.abspath(os.getcwd()), 'src', 'main_test.py')]
|
cmd_entrypoint = [os.path.join(os.path.abspath(os.getcwd()), 'src', 'main_test.py')]
|
||||||
|
@ -46,9 +37,18 @@ class TeleniumTestProcess(TeleniumTestCase):
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
"""Setupclass is for setting temp environment"""
|
"""Setupclass is for setting temp environment"""
|
||||||
os.environ["BITMESSAGE_HOME"] = tempfile.gettempdir()
|
os.environ["BITMESSAGE_HOME"] = tempfile.gettempdir()
|
||||||
populate_test_data()
|
cls.populate_test_data()
|
||||||
super(TeleniumTestProcess, cls).setUpClass()
|
super(TeleniumTestProcess, cls).setUpClass()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def populate_test_data():
|
||||||
|
"""Set temp data in tmp directory"""
|
||||||
|
for file_name in tmp_db_file:
|
||||||
|
old_source_file = os.path.join(
|
||||||
|
os.path.abspath(os.path.dirname(__file__)), 'sampleData', file_name)
|
||||||
|
new_destination_file = os.path.join(os.environ['BITMESSAGE_HOME'], file_name)
|
||||||
|
shutil.copyfile(old_source_file, new_destination_file)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
"""Ensures that pybitmessage stopped and removes files"""
|
"""Ensures that pybitmessage stopped and removes files"""
|
||||||
|
|
|
@ -1,19 +1,15 @@
|
||||||
import os
|
from telenium.client import TeleniumHttpException
|
||||||
import pdb
|
from .telenium_process import TeleniumTestProcess
|
||||||
import tempfile
|
|
||||||
from .telenium_process import TeleniumTestProcess, cleanup
|
|
||||||
from .common import ordered
|
from .common import ordered
|
||||||
from random import choice
|
from random import choice
|
||||||
from string import ascii_lowercase
|
from string import ascii_lowercase
|
||||||
|
|
||||||
class CreateRandomAddress(TeleniumTestProcess):
|
class CreateRandomAddress(TeleniumTestProcess):
|
||||||
"""This is for testing randrom address creation"""
|
"""This is for testing randrom address creation"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def populate_test_data(cls):
|
||||||
os.environ["BITMESSAGE_HOME"] = tempfile.gettempdir()
|
pass
|
||||||
cleanup()
|
|
||||||
super(TeleniumTestProcess, cls).setUpClass()
|
|
||||||
|
|
||||||
@ordered
|
@ordered
|
||||||
def test_login_screen(self):
|
def test_login_screen(self):
|
||||||
|
@ -21,17 +17,14 @@ class CreateRandomAddress(TeleniumTestProcess):
|
||||||
# Checking current Screen(Login screen)
|
# Checking current Screen(Login screen)
|
||||||
self.assert_wait_no_except('//ScreenManager[@current]', timeout=15, value='login')
|
self.assert_wait_no_except('//ScreenManager[@current]', timeout=15, value='login')
|
||||||
# Clicking on Proceed Next Button
|
# Clicking on Proceed Next Button
|
||||||
self.assertExists('//Screen[0]//MDFillRoundFlatIconButton[@text=\"Proceed Next\"]', timeout=2)
|
# self.assertExists('//Screen[0]//MDFillRoundFlatIconButton[@text=\"Proceed Next\"]', timeout=5)
|
||||||
self.cli.wait_click(
|
self.cli.wait_click('//Screen[0]//MDFillRoundFlatIconButton[@text=\"Proceed Next\"]', timeout=5)
|
||||||
'//Screen[0]//MDFillRoundFlatIconButton[@text=\"Proceed Next\"]', timeout=2)
|
# Checking Current Screen(Random Screen) after Clicking on "Proceed Next" Button
|
||||||
# Checking Current Screen(Random Screen) after Clicking on Proceed Next Button
|
|
||||||
# self.assertExists("//Random[@name~=\"random\"]", timeout=2)
|
|
||||||
try:
|
try:
|
||||||
self.assertExists("//ScreenManager[@current=\"random\"]", timeout=2)
|
self.assertExists("//ScreenManager[@current=\"random\"]", timeout=5)
|
||||||
except:
|
except TeleniumHttpException:
|
||||||
self.cli.wait_click(
|
self.cli.wait_click('//Screen[0]//MDFillRoundFlatIconButton[@text=\"Proceed Next\"]', timeout=5)
|
||||||
'//Screen[0]//MDFillRoundFlatIconButton[@text=\"Proceed Next\"]', timeout=5)
|
self.assertExists("//ScreenManager[@current=\"random\"]", timeout=5)
|
||||||
self.assertExists("//ScreenManager[@current=\"random\"]", timeout=2)
|
|
||||||
|
|
||||||
@ordered
|
@ordered
|
||||||
def test_random_screen(self):
|
def test_random_screen(self):
|
||||||
|
@ -102,6 +95,6 @@ class CreateRandomAddress(TeleniumTestProcess):
|
||||||
self.cli.wait_click('//MySpinnerOption[0]', timeout=5)
|
self.cli.wait_click('//MySpinnerOption[0]', timeout=5)
|
||||||
# Checking current screen
|
# Checking current screen
|
||||||
self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=5)
|
self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=5)
|
||||||
except:
|
except TeleniumHttpException:
|
||||||
self.cli.wait_click('//MySpinnerOption[0]', timeout=5)
|
self.cli.wait_click('//MySpinnerOption[0]', timeout=5)
|
||||||
self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=5)
|
self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=5)
|
||||||
|
|
|
@ -1,45 +1,34 @@
|
||||||
from time import time
|
from telenium.client import TeleniumHttpException
|
||||||
from .telenium_process import TeleniumTestProcess
|
from .telenium_process import TeleniumTestProcess
|
||||||
from .common import ordered
|
from .common import ordered
|
||||||
|
|
||||||
data = [
|
test_address = {'receiver': 'BM-2cWmjntZ47WKEUtocrdvs19y5CivpKoi1h'}
|
||||||
'BM-2cWmjntZ47WKEUtocrdvs19y5CivpKoi1h',
|
|
||||||
'BM-2cVpswZo8rWLXDVtZEUNcDQvnvHJ6TLRYr'
|
|
||||||
]
|
|
||||||
|
|
||||||
class SendMessage(TeleniumTestProcess):
|
class SendMessage(TeleniumTestProcess):
|
||||||
"""Sent Screen Functionality Testing"""
|
"""Sent Screen Functionality Testing"""
|
||||||
|
test_subject = 'Test Subject'
|
||||||
|
test_body = 'Hello, \n Hope your are doing good.\n\t This is test message body'
|
||||||
|
|
||||||
@ordered
|
@ordered
|
||||||
def test_send_message_and_validation(self):
|
def test_send_message_and_validation(self):
|
||||||
"""
|
"""
|
||||||
Sending Message From Inbox Screen
|
Sending Message From Inbox Screen
|
||||||
opens a pop-up(screen)which send message from sender to reciever
|
opens a pop-up(screen) which send message from sender to reciever
|
||||||
"""
|
"""
|
||||||
print("=======Test - Sending Message From Inbox Screen with validation Checks=======")
|
# Checking current Screen(Login screen)
|
||||||
self.cli.sleep(8)
|
self.assert_wait_no_except('//ScreenManager[@current]', timeout=10, value='login')
|
||||||
# this is for opening Nav drawer
|
|
||||||
self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=3)
|
|
||||||
# checking state of Nav drawer
|
|
||||||
self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=2)
|
|
||||||
# Click to open Inbox
|
|
||||||
self.cli.wait_click('//NavigationItem[@text=\"Inbox\"]', timeout=2)
|
|
||||||
# Checking Inbox Screen
|
|
||||||
self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=2)
|
|
||||||
# Due to animation and transition effect, it needed some halt otherwise it fails
|
|
||||||
self.cli.sleep(1)
|
|
||||||
# Click on Composer Icon(Plus icon)
|
# Click on Composer Icon(Plus icon)
|
||||||
self.cli.wait_click('//ComposerButton[0]/MDFloatingActionButton[@icon=\"plus\"]', timeout=2)
|
self.cli.wait_click('//ComposerButton[0]/MDFloatingActionButton[@icon=\"plus\"]', timeout=2)
|
||||||
# Checking Message Composer Screen(Create)
|
# Checking Message Composer Screen(Create)
|
||||||
self.assertExists("//Create[@name~=\"create\"]", timeout=4)
|
self.assertExists("//ScreenManager[@current=\"create\"]", timeout=4)
|
||||||
# Checking State of Sender's Address Input Field (Empty)
|
# Checking State of Sender's Address Input Field (Empty)
|
||||||
self.assertExists('//DropDownWidget/ScrollView[0]//MDTextField[@text=\"\"]', timeout=3)
|
self.assertExists('//DropDownWidget/ScrollView[0]//MDTextField[@text=\"\"]', timeout=3)
|
||||||
# Click on Receiver's Address Field to check validation
|
# Click on Receiver's Address Field to check validation
|
||||||
self.cli.wait_click('//DropDownWidget/ScrollView[0]//MyTextInput[@text=\"\"]', timeout=4)
|
# self.cli.wait_click('//DropDownWidget/ScrollView[0]//MyTextInput[@text=\"\"]', timeout=4)
|
||||||
# Checking State of Receiver's Address Input Field (Empty)
|
# Checking State of Receiver's Address Input Field (Empty)
|
||||||
self.assertExists('//DropDownWidget/ScrollView[0]//MyTextInput[@text=\"\"]', timeout=2)
|
self.assertExists('//DropDownWidget/ScrollView[0]//MyTextInput[@text=\"\"]', timeout=2)
|
||||||
# Click on Subject Field to check validation
|
# Click on Subject Field to check validation
|
||||||
self.cli.wait_click('//DropDownWidget/ScrollView[0]//MyMDTextField[@text=\"\"]', timeout=2)
|
# self.cli.wait_click('//DropDownWidget/ScrollView[0]//MyMDTextField[@text=\"\"]', timeout=2)
|
||||||
# Checking State of Subject Input Field (Empty)
|
# Checking State of Subject Input Field (Empty)
|
||||||
self.assertExists('//DropDownWidget/ScrollView[0]//MyMDTextField[@text=\"\"]', timeout=2)
|
self.assertExists('//DropDownWidget/ScrollView[0]//MyMDTextField[@text=\"\"]', timeout=2)
|
||||||
# Click on Send Icon to check validation working
|
# Click on Send Icon to check validation working
|
||||||
|
@ -49,70 +38,70 @@ class SendMessage(TeleniumTestProcess):
|
||||||
# Click on 'Ok' to dismiss the Popup
|
# Click on 'Ok' to dismiss the Popup
|
||||||
self.cli.wait_click('//MDFlatButton[0]', timeout=2)
|
self.cli.wait_click('//MDFlatButton[0]', timeout=2)
|
||||||
# Checking Pop up is closed
|
# Checking Pop up is closed
|
||||||
self.assertExists("//Create[@name~=\"create\"]", timeout=4)
|
self.assertExists("//ScreenManager[@current=\"create\"]", timeout=2)
|
||||||
|
|
||||||
# ADD SENDER'S ADDRESS
|
# ADD SENDER'S ADDRESS
|
||||||
# Checking State of Sender's Address Input Field (Empty)
|
# Checking State of Sender's Address Input Field (Empty)
|
||||||
self.assertExists('//DropDownWidget/ScrollView[0]//MDTextField[@text=\"\"]', timeout=2)
|
self.assertExists('//DropDownWidget/ScrollView[0]//MDTextField[@text=\"\"]', timeout=2)
|
||||||
# Open Sender's Address DropDown
|
# Open Sender's Address DropDown
|
||||||
self.cli.wait_click(
|
self.cli.wait_click('//Create//CustomSpinner[0]/ArrowImg[0]', timeout=3)
|
||||||
'//Create//CustomSpinner[0]/ArrowImg[0]', timeout=3)
|
|
||||||
# Due to animation and transition effect, it needed some halt otherwise it fails
|
# Due to animation and transition effect, it needed some halt otherwise it fails
|
||||||
self.cli.sleep(2)
|
# self.cli.sleep(2)
|
||||||
# Checking the Address Dropdown is in open State
|
# Checking the Address Dropdown is in open State
|
||||||
self.assertTrue('//Create//CustomSpinner[@is_open]', 'True')
|
# self.assertFalse('//Create//CustomSpinner[@is_open]', 'False')
|
||||||
# Select Sender's Address from Dropdown
|
# Select Sender's Address from Dropdown
|
||||||
self.cli.wait_click('//ComposerSpinnerOption[0]', timeout=3)
|
self.cli.wait_click('//ComposerSpinnerOption[0]', timeout=3)
|
||||||
# Checking the Address Dropdown is in open State
|
# Checking the Address Dropdown is in open State
|
||||||
self.assertTrue('//Create//CustomSpinner[@is_open]', 'False')
|
# self.assertTrue('//Create//CustomSpinner[@is_open]', 'False')
|
||||||
# Assert to check Sender's address dropdown open or not
|
# Assert to check Sender's address dropdown open or not
|
||||||
self.assertNotEqual('//DropDownWidget/ScrollView[0]//MDTextField[0]', '')
|
self.assertNotEqual('//DropDownWidget/ScrollView[0]//MDTextField[0]', '')
|
||||||
# ADD SUBJECT
|
# ADD SUBJECT
|
||||||
self.cli.setattr('//DropDownWidget/ScrollView[0]//MyMDTextField[0]', 'text', 'heyyyyyy')
|
self.cli.setattr('//DropDownWidget/ScrollView[0]//MyMDTextField[0]', 'text', self.test_subject)
|
||||||
# Checking Subject Field is Entered
|
# Checking Subject Field is Entered
|
||||||
self.assertExists('//DropDownWidget/ScrollView[0]//MyMDTextField[@text=\"heyyyyyy\"]', timeout=2)
|
self.assertNotEqual('//DropDownWidget/ScrollView[0]//MyMDTextField[text]', '')
|
||||||
# Checking BODY Field(EMPTY)
|
# Checking BODY Field(EMPTY)
|
||||||
self.assertExists('//DropDownWidget/ScrollView[0]//ScrollView[0]/MDTextField[@text=\"\"]', timeout=2)
|
self.assertExists('//DropDownWidget/ScrollView[0]//ScrollView[0]/MDTextField[@text=\"\"]', timeout=2)
|
||||||
# ADD BODY
|
# ADD BODY
|
||||||
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/MDTextField[0]',
|
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/MDTextField[0]', 'text', self.test_body)
|
||||||
'text', 'how are you this is message body')
|
|
||||||
# Checking BODY is Entered
|
# Checking BODY is Entered
|
||||||
self.assertExists(
|
self.assertNotEqual(
|
||||||
'//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/MDTextField[@text=\"how are you this is message body\"]', timeout=2)
|
'//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/MDTextField[text]', '')
|
||||||
# click on send icon
|
# click on send icon
|
||||||
self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"send\"]', timeout=2)
|
self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"send\"]', timeout=2)
|
||||||
# Checking validation so Pop up is Opened
|
# Checking validation so Pop up is Opened
|
||||||
self.assertExists('//MDDialog[@text=\"Please fill the form completely\"]', timeout=2)
|
self.assertExists('//MDDialog[@text=\"Please fill the form completely\"]', timeout=2)
|
||||||
# Pop clicked on ok
|
# clicked on ok button to close popup
|
||||||
self.cli.wait_click('//MDFlatButton[0]', timeout=2)
|
self.cli.wait_click('//MDFlatButton[0]', timeout=2)
|
||||||
|
self.assertExists("//ScreenManager[@current=\"create\"]", timeout=5)
|
||||||
# ADD RECEIVER ADDRESS
|
# ADD RECEIVER ADDRESS
|
||||||
# Checking Receiver Address Field
|
# Checking Receiver Address Field
|
||||||
self.assertExists('//DropDownWidget/ScrollView[0]//MyTextInput[@text=\"\"]', timeout=2)
|
self.assertExists('//DropDownWidget/ScrollView[0]//MyTextInput[@text=\"\"]', timeout=2)
|
||||||
# Entering Receiver Address
|
# Entering Receiver Address
|
||||||
self.cli.setattr(
|
self.cli.setattr('//DropDownWidget/ScrollView[0]//MyTextInput[0]', "text", test_address['receiver'])
|
||||||
'//DropDownWidget/ScrollView[0]//MyTextInput[0]', "text", data[0])
|
|
||||||
# Checking Receiver Address filled or not
|
# Checking Receiver Address filled or not
|
||||||
self.assertNotEqual('//DropDownWidget/ScrollView[0]//MyTextInput[0]', '')
|
self.assertNotEqual('//DropDownWidget/ScrollView[0]//MyTextInput[text]', '')
|
||||||
# Clicking on send icon
|
# Clicking on send icon
|
||||||
self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"send\"]', timeout=4)
|
self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"send\"]', timeout=5)
|
||||||
# Checking screen(Inbox) after sending message
|
# Checking screen(Inbox) after sending message
|
||||||
self.assertExists("//Inbox[@name~=\"inbox\"]", timeout=4)
|
try:
|
||||||
|
self.assertExists("//ScreenManager[@current=\"inbox\"]", timeout=10)
|
||||||
|
except TeleniumHttpException:
|
||||||
|
self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"send\"]', timeout=4)
|
||||||
|
self.assertExists("//ScreenManager[@current=\"inbox\"]", timeout=10)
|
||||||
|
|
||||||
@ordered
|
@ordered
|
||||||
def test_sent_box(self):
|
def test_sent_box(self):
|
||||||
"""
|
"""
|
||||||
Checking Message in Sent Screen after sending a Message.
|
Checking Message in Sent Screen after sending a Message.
|
||||||
"""
|
"""
|
||||||
print("=======Test - Checking Message in Sent Screen after sending a Message=======")
|
|
||||||
# this is for opening Nav drawer
|
# this is for opening Nav drawer
|
||||||
self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=3)
|
self.cli.wait_click('//MDActionTopAppBarButton[@icon=\"menu\"]', timeout=5)
|
||||||
# checking state of Nav drawer
|
# checking state of Nav drawer
|
||||||
self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=2)
|
self.assertExists("//MDNavigationDrawer[@state~=\"open\"]", timeout=5)
|
||||||
# Clicking on Sent Tab
|
# Clicking on Sent Tab
|
||||||
self.cli.wait_click('//NavigationItem[@text=\"Sent\"]', timeout=3)
|
self.cli.wait_click('//NavigationItem[@text=\"Sent\"]', timeout=5)
|
||||||
# Checking current screen; Sent
|
# Checking current screen; Sent
|
||||||
self.assertExists("//Sent[@name~=\"sent\"]", timeout=3)
|
self.assertExists("//ScreenManager[@current=\"sent\"]", timeout=5)
|
||||||
# It takes time to reload sent messages so used sleep method
|
|
||||||
self.cli.sleep(1)
|
|
||||||
# Checking number of Sent messages
|
# Checking number of Sent messages
|
||||||
total_sent_msgs = len(self.cli.select("//SwipeToDeleteItem"))
|
total_sent_msgs = len(self.cli.select("//SwipeToDeleteItem"))
|
||||||
self.assertEqual(total_sent_msgs, 2)
|
self.assertEqual(total_sent_msgs, 3)
|
||||||
|
|
Reference in New Issue
Block a user