added test data for tests

This commit is contained in:
navjot 2021-03-07 03:09:14 +05:30
parent 569fe43871
commit 29bf54905c
No known key found for this signature in database
GPG Key ID: 9EE70AFD71357F1C
5 changed files with 83 additions and 36 deletions

View File

@ -1,15 +1,84 @@
import os
import psutil
import shutil
import tempfile
from telenium.tests import TeleniumTestCase
from bitmessagekivy.tests.test_process_data import TestProcessProto
class TeleniumTestProcess(TestProcessProto, TeleniumTestCase):
_files = (
'keys.dat', 'debug.log', 'messages.dat', 'knownnodes.dat',
'.api_started', 'unittest.lock'
)
tmp_db_file = (
'keys.dat', 'messages.dat'
)
def cleanup(home=None, files=_files):
"""Cleanup application files"""
if not home:
home = tempfile.gettempdir()
for pfile in files:
try:
# import pdb;pdb.set_trace()
os.remove(os.path.join(home, pfile))
print(__file__,'.........................................(clean)', pfile)
except OSError:
print('error............................................')
pass
def set_temp_data():
for file in tmp_db_file:
old_source_file = os.path.join(
os.path.abspath(os.path.dirname(__file__)), 'sampleData', file)
new_destination_file = os.path.join(os.environ['BITMESSAGE_HOME'], file)
shutil.copyfile(old_source_file, new_destination_file)
class TeleniumTestProcess(TeleniumTestCase):
"""Setting Screen Functionality Testing"""
cmd_entrypoint = ['/home/cis/py3porting/Chatroom/PyBitmessage/src/main.py']
@classmethod
def setUpClass(cls):
print('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
def setUpClass(cls, is_login_screen=None):
print('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', is_login_screen)
os.environ["BITMESSAGE_HOME"] = tempfile.gettempdir()
TeleniumTestCase.start_process()
if is_login_screen:
cleanup()
else:
set_temp_data()
super(TeleniumTestProcess, cls).setUpClass()
# @classmethod
# def tearDownClass(cls):
# """Ensures that pybitmessage stopped and removes files"""
# print('tearDownClass.........................................(pass)')
# try:
# if not cls._stop_process(1):
# processes = cls.process.children(recursive=True)
# processes.append(cls.process)
# for p in processes:
# try:
# p.kill()
# except psutil.NoSuchProcess:
# pass
# except psutil.NoSuchProcess:
# pass
# finally:
# # import pdb;pdb.set_trace()
# cleanup()
# # cls._cleanup_files()
# @classmethod
# def _stop_process(cls, timeout=5):
# print('_stop_process.........................................(pass)')
# import signal
# cls.process.send_signal(signal.SIGTERM)
# try:
# cls.process.wait(timeout)
# except psutil.TimeoutExpired:
# return False
# return True

View File

@ -20,7 +20,7 @@ class AllMailMessage(TeleniumTestProcess):
time.sleep(4)
self.cli.click_on('//Allmails[0]/BoxLayout[0]/BoxLayout[0]/ScrollView[0]/MDList[0]/Carousel[0]')
time.sleep(5)
self.cli.click_on('//MDToolbar/BoxLayout[2]/MDIconButton[0]')
self.cli.click_on('//MDToolbar/BoxLayout[2]/MDIconButton[1]')
time.sleep(3)

View File

@ -1,7 +1,5 @@
# import state
import os
import tempfile
# state.appdata = tempfile.gettempdir()
import time
from random import choice
from string import ascii_lowercase
@ -9,10 +7,6 @@ from bitmessagekivy.tests.telenium_process import TeleniumTestProcess
class CreateRandomAddress(TeleniumTestProcess):
@classmethod
def setUpClass(cls):
super(CreateRandomAddress, cls).setUpClass()
def test_login_screen(self):
"""Clicking on Proceed Button to Proceed to Next Screen."""
@ -64,21 +58,14 @@ class CreateRandomAddress(TeleniumTestProcess):
time.sleep(2)
self.cli.click_on('//MySpinnerOption[0]')
# def test_export_csv(self):
# self.cli.wait_click("//SaveButton")
# self.cli.wait_click("//CascadeSaveButton")
# self.cli.wait_click("//SaveCSVButton")
# self.assertExists("//Label[@text~=\"Export to CSV\"]", timeout=2)
# self.cli.wait_click("//FitButton[@text=\"Close\"]", timeout=2)
# self.assertNotExists("//Label[@text~=\"Export to CSV\"]", timeout=2)
if __name__ == '__main__':
"""Start Application"""
obj = CreateRandomAddress()
obj.setUpClass() # this is for showing another process running error
obj.setUpClass(True) # this is for showing another process running error
obj.test_login_screen()
obj.test_random_screen()
obj.test_create_new_address()
obj.test_random_screen()
obj.test_select_address()
obj.remove_temp_data()
# obj.remove_temp_data()

View File

@ -7,23 +7,11 @@ import time
from bitmessagekivy.tests.telenium_process import TeleniumTestProcess
from bmconfigparser import BMConfigParser
data = []
class SendMessage(TeleniumTestProcess):
"""Sent Screen Functionality Testing"""
def __init__(self):
print('you are inside telenium init...................................................................................')
# import pdb;pdb.set_trace()
old_source_file = os.path.join(
os.path.abspath(os.path.dirname(__file__)), 'sampleData', 'keys.dat')
# new_destination_file = os.path.join(tempfile.gettempdir(), 'keys.dat')
if not os.path.exists(os.environ['BITMESSAGE_HOME']):
os.mkdir(os.environ['BITMESSAGE_HOME'])
new_destination_file = os.path.join(os.environ['BITMESSAGE_HOME'], 'keys.dat')
shutil.copyfile(old_source_file, new_destination_file)
self.data = BMConfigParser().addresses()
# print(__file__, '...............................addreses in configfile', BMConfigParser().addresses())
def test_select_sent(self):
"""Sending Message From Inbox Screen
opens a pop-up(screen)which send message from sender to reciever"""
@ -70,7 +58,7 @@ class SendMessage(TeleniumTestProcess):
time.sleep(3)
self.cli.click_on('//MDFlatButton[0]')
time.sleep(6)
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[1]/BoxLayout[0]/MyTextInput[0]',"text",self.data[0])
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[1]/BoxLayout[0]/MyTextInput[0]',"text", data[0])
time.sleep(3)
self.cli.click_on('//MDIconButton[2]')
time.sleep(3)
@ -85,7 +73,7 @@ class SendMessage(TeleniumTestProcess):
# self.cli.execute('app.root.ids.nav_drawer.set_state("toggle")')
self.cli.execute('app.clickNavDrawer()')
time.sleep(5)
self.cli.click_on('//NavigationItem[1]')
self.cli.click_BMConfigParseron('//NavigationItem[1]')
time.sleep(3)
self.cli.click_on('//Inbox/ComposerButton[0]/MDFloatingActionButton[0]')
time.sleep(3)
@ -94,7 +82,7 @@ class SendMessage(TeleniumTestProcess):
self.cli.click_on('//MyTextInput[0]')
time.sleep(3)
data = BMConfigParser().addresses()
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[1]/BoxLayout[0]/MyTextInput[0]', "text", self.data[0])
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[1]/BoxLayout[0]/MyTextInput[0]', "text", data[0])
time.sleep(3)
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/MyMDTextField[0]', 'text', 'Second')
time.sleep(3)
@ -116,6 +104,8 @@ if __name__ == '__main__':
"""Start Application"""
obj = SendMessage()
obj.setUpClass()
# obj.set_temp_data()
# import pdb;pdb.set_trace()
obj.test_select_sent()
obj.test_sent_multiple_message()
obj.remove_temp_data()

View File

@ -26,3 +26,4 @@ if __name__ == '__main__':
obj = SettingScreen()
obj.setUpClass()
obj.test_setting_screen()
# obj.tearDownClass()