created separate module for each functionality

This commit is contained in:
navjot 2021-03-04 04:28:11 +05:30
parent da75352bc9
commit df2dd7eeda
No known key found for this signature in database
GPG Key ID: 9EE70AFD71357F1C
13 changed files with 636 additions and 797 deletions

View File

@ -1,4 +1,5 @@
import state
print('state.appdata (mpybit.py line no. (1))....................................', state.appdata)
# pylint: disable=too-many-lines,import-error,no-name-in-module,unused-argument
# pylint: disable=too-many-ancestors,too-many-locals,useless-super-delegation
# pylint: disable=protected-access
@ -902,6 +903,8 @@ class DropDownWidget(BoxLayout):
def send(self, navApp):
"""Send message from one address to another"""
print('in send check state.appdata................................')
print('state.appdata....................................', state.appdata)
fromAddress = self.ids.ti.text.strip()
toAddress = self.ids.txt_input.text.strip()
subject = self.ids.subject.text.strip()
@ -1323,6 +1326,8 @@ class Random(Screen):
def generateaddress(self, navApp):
"""Method for Address Generator"""
# entered_label = str(self.ids.lab.text).strip()
print('address creation.........999999999999999999999999999')
print('state.appdata....................................', state.appdata)
entered_label = str(self.ids.add_random_bx.children[0].ids.lab.text).strip()
if not entered_label:
self.ids.add_random_bx.children[0].ids.lab.focus = True

View File

View File

@ -0,0 +1,93 @@
import state
import os
import tempfile
state.appdata = tempfile.gettempdir()
import time
from random import choice
from string import ascii_lowercase
from telenium.tests import TeleniumTestCase
from tests.test_process import TestProcessProto, TestProcessShutdown
class CreateRandomAddress(TestProcessProto, TeleniumTestCase):
cmd_entrypoint = ['/home/cis/py3porting/Chatroom/PyBitmessage/src/main.py']
# @classmethod
# def setUpClass(cls):
# print('inside class Method..............................................9')
# pass
def test_runTest(self):
"""Test Run Method."""
print(self,"=====================Welcome To Kivy Testing Application=====================")
def test_login_screen(self):
"""Clicking on Proceed Button to Proceed to Next Screen."""
print("=====================Test - Login Screen=====================")
time.sleep(3)
self.cli.wait_click('//Login/BoxLayout[0]/BoxLayout[0]/ScreenManager[0]/Screen[0]/BoxLayout[0]/AnchorLayout[3]/MDFillRoundFlatIconButton[0]')
time.sleep(3)
def test_random_screen(self):
"""Creating New Adress For New User."""
print("=====================Test - Create New Address=====================")
self.cli.click_on('//RandomBoxlayout/BoxLayout[0]/AnchorLayout[1]/MDTextField[0]')
time.sleep(3)
self.cli.wait_click('//RandomBoxlayout/BoxLayout[0]/AnchorLayout[2]/MDFillRoundFlatIconButton[0]')
time.sleep(3)
self.cli.click_on('//RandomBoxlayout/BoxLayout[0]/AnchorLayout[1]/MDTextField[0]')
time.sleep(3)
random_label = ""
for _ in range(10):
random_label += choice(ascii_lowercase)
self.cli.setattr('//RandomBoxlayout/BoxLayout[0]/AnchorLayout[1]/MDTextField[0]', "text", random_label)
time.sleep(0.2)
time.sleep(1)
self.cli.wait_click('//RandomBoxlayout/BoxLayout[0]/AnchorLayout[2]/MDFillRoundFlatIconButton[0]')
time.sleep(5)
def test_create_new_address(self):
"""Clicking on Navigation Drawer To Open New Address"""
print("=====================Test - Create New Address=====================")
time.sleep(5)
self.cli.execute('app.root.ids.nav_drawer.set_state("toggle")')
time.sleep(2)
self.cli.drag("//NavigationItem[@text=\"Sent\"]","//NavigationItem[@text=\"Inbox\"]",1)
time.sleep(3)
self.cli.click_on('//NavigationItem[9]')
time.sleep(4)
self.cli.wait_click('//Login/BoxLayout[0]/BoxLayout[0]/ScreenManager[0]/Screen[0]/BoxLayout[0]/AnchorLayout[3]/MDFillRoundFlatIconButton[0]')
def test_select_address(self):
"""Select First Address From Drawer-Box"""
print("=====================Test - Select First Address From Drawer-Box=======================")
time.sleep(3)
# self.cli.execute('app.root.ids.nav_drawer.set_state("toggle")')
self.cli.execute('app.clickNavDrawer()')
time.sleep(2)
self.cli.drag("//NavigationItem[@text=\"Address Book\"]","//NavigationItem[@text=\"Settings\"]",1)
time.sleep(2)
self.cli.click_on('//NavigationItem[0]')
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"""
TeleniumTestCase.start_process()
obj = CreateRandomAddress()
obj.setUpClass()
print(state.appdata, '===================================^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', os.environ['BITMESSAGE_HOME'])
obj.test_runTest()
obj.test_login_screen()
obj.test_random_screen()
obj.test_create_new_address()
obj.test_random_screen()
obj.test_select_address()

View File

@ -0,0 +1,109 @@
import time
from telenium.tests import TeleniumTestCase
class DraftMessage(TeleniumTestCase):
"""Draft Screen Functionality Testing"""
def runTest(self):
print(self,"-------------Welcome To Kivy Testing Application Fourth Page-------------")
def test_select_draft_message(self):
"""Select A Draft Screen From Navigaion-Drawer-Box Then
Send a drafted message """
print("=====================Test - Select A Draft Screen From Navigaion-Drawer-Box=====================")
# OPEN NAVIGATION-DRAWER
time.sleep(4)
self.cli.execute('app.clickNavDrawer()')
time.sleep(2)
# OPEN INBOX SCREEN
self.cli.click_on('//NavigationItem[1]')
time.sleep(2)
# CLICK ON PLUS ICON BUTTON
self.cli.click_on('//Inbox/ComposerButton[0]/MDFloatingActionButton[0]')
time.sleep(3)
# SELECT - TO ADDRESS
self.cli.click_on('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[0]/BoxLayout[0]/CustomSpinner[0]/ArrowImg[0]')
time.sleep(2)
self.cli.click_on('//MyTextInput[0]')
time.sleep(3)
# ADD FROM MESSAGE
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[1]/BoxLayout[0]/MyTextInput[0]', "text",'BM-2cSsuH1bUWBski8bvdqnK2DivMqQCeQA1J')
time.sleep(3)
# CLICK BACK-BUTTON
self.cli.click_on('//MDToolbar/BoxLayout[0]/MDIconButton[0]')
time.sleep(5)
self.cli.click_on('//Inbox/ComposerButton[0]/MDFloatingActionButton[0]')
time.sleep(3)
# SELECT - TO ADDRESS
self.cli.click_on('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[0]/BoxLayout[0]/CustomSpinner[0]/ArrowImg[0]')
time.sleep(1)
self.cli.click_on('//MyTextInput[0]')
time.sleep(3)
# ADD FROM MESSAGE
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[1]/BoxLayout[0]/MyTextInput[0]', "text",'BM-2cSsuH1bUWBski8bvdqnK2DivMqQCeQA1J')
time.sleep(4)
random_label=""
for char in "Another Draft message":
random_label += char
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/MyMDTextField[0]', 'text', random_label)
time.sleep(0.2)
# CLICK BACK-BUTTON
self.cli.click_on('//MDToolbar/BoxLayout[0]/MDIconButton[0]')
time.sleep(4)
def test_edit_draft_messgae(self):
"""Select A Message From List of Messages Then
make changes and send it."""
print("=====================Test - Edit A Message From Draft Screen=====================")
# OPEN NAVIGATION-DRAWER
self.cli.execute('app.clickNavDrawer()')
time.sleep(4)
# OPEN DRAFT SCREEN
self.cli.click_on('//NavigationItem[3]')
time.sleep(4)
# SHOW DRAFT MESSAGE AND SELECT FIRST MESSAGE
self.cli.click_on('//Carousel[0]//TwoLineAvatarIconListItem[0]')
time.sleep(3)
# CLICK EDIT BUTTON
self.cli.click_on('//MDToolbar/BoxLayout[2]/MDIconButton[0]')
time.sleep(5)
random_label=""
for char in "Hey,This is draft Message Body":
random_label += char
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/TextInput[0]', 'text', random_label)
time.sleep(0.2)
time.sleep(3)
self.cli.click_on('//MDIconButton[2]')
time.sleep(5)
def test_delete_draft_message(self):
"""Delete A Message From List of Messages"""
print("=====================Test - Delete A Message From List of Messages=====================")
time.sleep(5)
# self.cli.execute('app.root.ids.nav_drawer.set_state("toggle")')
self.cli.execute('app.clickNavDrawer()')
time.sleep(4)
self.cli.click_on('//NavigationItem[3]')
time.sleep(5)
self.cli.click_on('//Carousel[0]//TwoLineAvatarIconListItem[0]')
time.sleep(5)
self.cli.click_on('//MDToolbar/BoxLayout[2]/MDIconButton[1]')
time.sleep(2)
def test_all_draft_method(self):
"""Calling All The Methods Draft Class"""
self.test_select_draft_message()
self.test_edit_draft_messgae()
self.test_delete_draft_message()
if __name__ == '__main__':
"""Start Application"""
import tempfile
import state
state.appdata = tempfile.gettempdir()
print('state.appdata..........................(105)', state.appdata)
TeleniumTestCase.start_process()
obj = DraftMessage()
obj.test_all_draft_method()

View File

@ -0,0 +1,103 @@
import time
from bmconfigparser import BMConfigParser
from telenium.tests import TeleniumTestCase
class SendMessage(TeleniumTestCase):
"""Sent Screen Functionality Testing"""
def runTest(self):
print(self,"-------------Welcome To Kivy Testing Application Thirds Page-------------")
def test_select_sent(self):
"""Sending Message From Inbox Screen
opens a pop-up(screen)which send message from sender to reciever"""
print("=====================Test - Sending Message From Inbox Screen=====================")
time.sleep(2)
self.cli.execute('app.root.ids.nav_drawer.set_state("toggle")')
time.sleep(1)
self.cli.click_on('//NavigationItem[1]')
time.sleep(1)
self.cli.click_on('//Inbox/ComposerButton[0]/MDFloatingActionButton[0]')
time.sleep(3)
self.cli.click_on('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[0]/MyMDTextField[0]')
time.sleep(3)
self.cli.click_on('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[1]/MyTextInput[0]')
time.sleep(3)
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[1]/MyTextInput[0]', "text", "second add")
time.sleep(3)
self.cli.click_on('//DropDownWidget/ScrollView[0]/BoxLayout[0]/MyMDTextField[0]')
time.sleep(4)
self.cli.click_on('//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/TextInput[0]')
time.sleep(4)
self.cli.click_on('//MDIconButton[2]')
time.sleep(3)
self.cli.click_on('//MDFlatButton[0]')
time.sleep(5)
self.cli.click_on('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[0]/BoxLayout[0]/CustomSpinner[0]/ArrowImg[0]')
time.sleep(2)
self.cli.click_on('//MyTextInput[0]')
time.sleep(3)
self.cli.click_on('//DropDownWidget/ScrollView[0]/BoxLayout[0]/MyMDTextField[0]')
time.sleep(2)
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/MyMDTextField[0]', 'text', 'heyyyyyy')
time.sleep(3)
self.cli.click_on('//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/TextInput[0]')
time.sleep(4)
random_label=""
for char in "how are you this is message body":
random_label += char
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/TextInput[0]','text',random_label)
time.sleep(0.2)
time.sleep(3)
self.cli.click_on('//MDIconButton[2]')
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",data[0])
time.sleep(3)
self.cli.click_on('//MDIconButton[2]')
time.sleep(3)
self.cli.click_on('//MDFlatButton[0]')
time.sleep(3)
def test_sent_multiple_message(self):
"""Sending Second Message From Inbox Screen
for testing the search and delete functionality for two messages on the screen"""
print("=====================Test - Sending Message From Inbox Screen=====================")
time.sleep(3)
self.cli.execute('app.root.ids.nav_drawer.set_state("toggle")')
time.sleep(5)
self.cli.click_on('//NavigationItem[1]')
time.sleep(3)
self.cli.click_on('//Inbox/ComposerButton[0]/MDFloatingActionButton[0]')
time.sleep(3)
self.cli.click_on('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[0]/BoxLayout[0]/CustomSpinner[0]/ArrowImg[0]')
time.sleep(2)
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", data[0])
time.sleep(3)
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/MyMDTextField[0]', 'text', 'Second')
time.sleep(3)
random_label=""
for char in "Hey This Is Second Message Body":
random_label += char
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/TextInput[0]',"text",random_label)
time.sleep(0.2)
time.sleep(2)
self.cli.click_on('//MDIconButton[2]')
time.sleep(5)
self.cli.execute('app.clickNavDrawer()')
time.sleep(3)
self.cli.click_on('//NavigationItem[2]')
time.sleep(3)
if __name__ == '__main__':
"""Start Application"""
TeleniumTestCase.start_process()
obj = SendMessage()
obj.test_select_sent()
obj.test_sent_multiple_message()

View File

@ -150,6 +150,9 @@ class Main(object):
def start(self):
"""Start main application"""
# pylint: disable=too-many-statements,too-many-branches,too-many-locals
# import tempfile
# state.appdata = tempfile.gettempdir()
print('line..........................153(state.appdata)...', state.appdata)
_fixSocket()
adjustHalfOpenConnectionsLimit()
@ -165,6 +168,7 @@ class Main(object):
self.usage()
sys.exit(2)
print('opts......................', opts)
for opt, _ in opts:
if opt in ("-h", "--help"):
self.usage()
@ -255,6 +259,9 @@ class Main(object):
singleWorkerThread.start()
# Start the SQL thread
# import tempfile
# state.appdata = tempfile.gettempdir()
print('state.appdata..........................(258)', state.appdata)
sqlLookup = sqlThread()
# DON'T close the main program even if there are threads left.
# The closeEvent should command this thread to exit gracefully.

View File

@ -28,6 +28,7 @@ class sqlThread(threading.Thread):
def run(self): # pylint: disable=too-many-locals, too-many-branches, too-many-statements
"""Process SQL queries from `.helper_sql.sqlSubmitQueue`"""
print('state.appdata..............................(31)', state.appdata)
self.conn = sqlite3.connect(state.appdata + 'messages.dat')
self.conn.text_factory = str
self.cur = self.conn.cursor()

View File

@ -1,120 +0,0 @@
import time
from telenium.tests import TeleniumTestCase
import random
import string
import os
import test_telenium_cases
from random import choice
from string import ascii_lowercase
class Bitmessage_Login_Screen(TeleniumTestCase):
"""Login Functionality Testing"""
cmd_entrypoint = [u'/home/cis/py3porting/Chatroom/PyBitmessage/src/main.py']
def runTest(self):
"""Test Run Method."""
print(self,"=====================Welcome To Kivy Testing Application=====================")
def test_login_screen(self):
"""Clicking on Proceed Button to Proceed to Next Screen."""
print("=====================Test - Login Screen=====================")
time.sleep(3)
self.cli.wait_click('//Login/BoxLayout[0]/BoxLayout[0]/ScreenManager[0]/Screen[0]/BoxLayout[0]/AnchorLayout[3]/MDFillRoundFlatIconButton[0]')
time.sleep(3)
def test_random_screen(self):
"""Creating New Adress For New User."""
print("=====================Test - Create New Address=====================")
self.cli.click_on('//RandomBoxlayout/BoxLayout[0]/AnchorLayout[1]/MDTextField[0]')
time.sleep(3)
self.cli.wait_click('//RandomBoxlayout/BoxLayout[0]/AnchorLayout[2]/MDFillRoundFlatIconButton[0]')
time.sleep(3)
self.cli.click_on('//RandomBoxlayout/BoxLayout[0]/AnchorLayout[1]/MDTextField[0]')
time.sleep(3)
random_label = ""
for _ in range(10):
random_label += choice(ascii_lowercase)
self.cli.setattr('//RandomBoxlayout/BoxLayout[0]/AnchorLayout[1]/MDTextField[0]', "text", random_label)
time.sleep(0.2)
time.sleep(1)
self.cli.wait_click('//RandomBoxlayout/BoxLayout[0]/AnchorLayout[2]/MDFillRoundFlatIconButton[0]')
time.sleep(5)
if __name__ == '__main__':
"""Start Application"""
TeleniumTestCase.start_process()
Bitmessage_Login_Screen().runTest()
print("==================start from first screen=====================")
f=open("/home/cis/.config/PyBitmessage/keys.dat")
get_file=f.read()
find_address=get_file.find("label")
print('m...................................', find_address)
if find_address != -1:
print('in if....................................')
# select_address=test_telenium_cases.Bitmessage_Select_Address()
# select_address.test_check_already_created_address()
# select_address.test_calling_all_methods()
# sent_message=test_telenium_cases.Bitmessage_Sent_Screen_Message()
# sent_message.test_select_sent()
# sent_message.test_sent_multiple_message()
# inbox_message=test_telenium_cases.Bitmessage_Inbox_Screen_Message()
# inbox_message.test_all_inbox_method()
# sent_message.test_all_sent_method()
# # sent_message.test_archive_sent_message_from_list()
# draft_message=test_telenium_cases.Bitmessage_Draft_Screen_Message()
# draft_message.test_all_draft_method()
# trash_message=test_telenium_cases.Bitmessage_Trash_Screen_Message()
# trash_message.test_delete_trash_message()
# all_mails=test_telenium_cases.Bitmessage_AllMail_Screen_Message()
# all_mails.test_select_all_mails()
# all_mails.test_delete_message_from_draft()
select_address=test_telenium_cases.Bitmessage_Select_Address()
select_address.test_calling_all_methods()
address_book=test_telenium_cases.Bitmessage_AddressBook_Screen_Message()
address_book.test_all_address_book_method()
setting=test_telenium_cases.Bitmessage_Setting_Screen()
setting.test_setting()
existing_Address=test_telenium_cases.Bitmessage_MyAddress_Screen_Message()
existing_Address.test_select_myaddress_list()
existing_Address.test_show_Qrcode()
existing_Address.test_send_message_from()
subscription_payment=test_telenium_cases.Bitmessage_SubscriptionPayment_Screen()
subscription_payment.test_select_subscripton()
credits=test_telenium_cases.Bitmessage_Credits_Screen()
credits.test_check_credits()
network_status=test_telenium_cases.Bitmessage_NetwrokStatus_Screen()
network_status.test_total_selection()
else :
Bitmessage_Login_Screen().test_login_screen()
Bitmessage_Login_Screen().test_random_screen()
new_address=test_telenium_cases.Bitmessage_Create_New_Address()
new_address.test_create_new_address()
Bitmessage_Login_Screen().test_random_screen()
select_address=test_telenium_cases.Bitmessage_Select_Address()
select_address.test_calling_all_methods()
sent_message=test_telenium_cases.Bitmessage_Sent_Screen_Message()
sent_message.test_select_sent()
sent_message.test_sent_multiple_message()
inbox_message=test_telenium_cases.Bitmessage_Inbox_Screen_Message()
inbox_message.test_all_inbox_method()
sent_message.test_all_sent_method()
draft_message=test_telenium_cases.Bitmessage_Draft_Screen_Message()
draft_message.test_all_draft_method()
trash_message=test_telenium_cases.Bitmessage_Trash_Screen_Message()
trash_message.test_delete_trash_message()
all_mails=test_telenium_cases.Bitmessage_AllMail_Screen_Message()
all_mails.test_select_all_mails()
all_mails.test_delete_message_from_draft()
address_book=test_telenium_cases.Bitmessage_AddressBook_Screen_Message()
address_book.test_all_address_book_method()
setting=test_telenium_cases.Bitmessage_Setting_Screen()
setting.test_setting()
existing_Address=test_telenium_cases.Bitmessage_MyAddress_Screen_Message()
existing_Address.test_select_myaddress_list()
existing_Address.test_show_Qrcode()
existing_Address.test_send_message_from()
subscription_payment=test_telenium_cases.Bitmessage_SubscriptionPayment_Screen()
subscription_payment.test_select_subscripton()
network_status=test_telenium_cases.Bitmessage_NetwrokStatus_Screen()
network_status.test_total_selection()

View File

@ -1,634 +0,0 @@
from telenium.tests import TeleniumTestCase
import time
import random
import string
import os
data=[]
class Bitmessage_Create_New_Address(TeleniumTestCase):
"""Generate New Address Functionality Testing"""
def runTest(self):
print(self,"-------------Welcome To Kivy Testing Application Thirteenth Page-------------")
def test_create_new_address(self):
"""Clicking on Navigation Drawer To Open New Address"""
print("=====================Test - Create New Address=====================")
time.sleep(5)
self.cli.execute('app.root.ids.nav_drawer.set_state("toggle")')
time.sleep(2)
self.cli.drag("//NavigationItem[@text=\"Sent\"]","//NavigationItem[@text=\"Inbox\"]",1)
time.sleep(3)
self.cli.click_on('//NavigationItem[9]')
time.sleep(4)
self.cli.wait_click('//Login/BoxLayout[0]/BoxLayout[0]/ScreenManager[0]/Screen[0]/BoxLayout[0]/AnchorLayout[3]/MDFillRoundFlatIconButton[0]')
class Bitmessage_Select_Address(TeleniumTestCase):
"""Select Address Functionality Testing"""
def runTest(self):
print(self,"-------------Welcome To Kivy Testing Application second Page-------------")
def test_check_already_created_address(self):
"""Check The Address Is Already Created Or Not"""
print("=====================Test - Select Address From Navigation Drawer=====================")
time.sleep(6)
self.cli.execute('app.root.toggle_nav_drawer()')
time.sleep(4)
self.cli.drag("//NavigationDrawerSubheader[@text=\"All labels\"]","//NavigationDrawerIconButton[@text=\"All Mails\"]",1)
time.sleep(3)
self.cli.click_on('//NavigationDrawerIconButton[12]')
time.sleep(4)
def test_select_second_address(self):
"""Select Text From Second Address Generated"""
print("=====================Test - Select Text From Second Address Created====================")
global data
time.sleep(3)
second_address=self.cli.getattr("//CustomTwoLineAvatarIconListItem[0]","secondary_text")
first_address=self.cli.getattr("//CustomTwoLineAvatarIconListItem[1]","secondary_text")
data.append(second_address)
data.append(first_address)
print('DATA...........................:-', data)
return data
def test_select_address(self):
"""Select First Address From Drawer-Box"""
print("=====================Test - Select First Address From Drawer-Box=======================")
time.sleep(3)
# self.cli.execute('app.root.ids.nav_drawer.set_state("toggle")')
self.cli.execute('app.clickNavDrawer()')
time.sleep(2)
self.cli.drag("//NavigationItem[@text=\"Address Book\"]","//NavigationItem[@text=\"Settings\"]",1)
time.sleep(2)
self.cli.click_on('//NavigationItem[0]')
time.sleep(2)
self.cli.click_on('//MySpinnerOption[0]')
def test_calling_all_methods(self):
self.test_select_second_address()
self.test_select_address()
class Bitmessage_Inbox_Screen_Message(TeleniumTestCase):
"""Inbox Screen Functionality Testing"""
def runTest(self):
print(self,"-------------Welcome To Kivy Testing Application For Inbox Screen-------------")
def test_select_inbox_of_second_address(self):
"""Select Inbox Screen From Navigation-Drawer-Box"""
print("=====================Test - Select Second Address From Drawer-Box=======================")
time.sleep(2)
self.cli.execute('app.root.ids.nav_drawer.set_state("toggle")')
time.sleep(3)
self.cli.click_on('//NavigationItem[0]')
time.sleep(3)
self.cli.click_on('//MySpinnerOption[1]')
time.sleep(2)
def test_show_inbox_message(self):
"""Select First Message from Inbox Screen"""
print("=====================Test - Select First Message from Inbox Screen=====================")
time.sleep(1)
self.cli.execute('app.clickNavDrawer()')
time.sleep(4)
self.cli.click_on('//TwoLineAvatarIconListItem[0]')
time.sleep(3)
self.cli.click_on('//MDIconButton[0]')
time.sleep(3)
def test_delete_inbox_message(self):
"""Deleting Message From Inbox Screen"""
print("=====================Test - Deleting Message From Inbox Screen=====================")
time.sleep(4)
self.cli.drag('//Inbox/BoxLayout[0]/BoxLayout[0]/ScrollView[0]/MDList[0]/Carousel[0]//TwoLineAvatarIconListItem[0]/BoxLayout[0]',
'//Inbox/BoxLayout[0]/BoxLayout[0]/ScrollView[0]/MDList[0]/Carousel[0]//TwoLineAvatarIconListItem[0]/BoxLayout[2]', 2)
time.sleep(2)
self.cli.click_on('//Inbox/BoxLayout[0]/BoxLayout[0]/ScrollView[0]/MDList[0]/Carousel[0]//Button[0]')
time.sleep(4)
def test_all_inbox_method(self):
"""Calling All The Methods Inbox Class"""
self.test_select_inbox_of_second_address()
self.test_show_inbox_message()
self.test_delete_inbox_message()
class Bitmessage_Sent_Screen_Message(TeleniumTestCase):
"""Sent Screen Functionality Testing"""
def runTest(self):
print(self,"-------------Welcome To Kivy Testing Application Thirds Page-------------")
def test_select_sent(self):
"""Sending Message From Inbox Screen
opens a pop-up(screen)which send message from sender to reciever"""
print("=====================Test - Sending Message From Inbox Screen=====================")
time.sleep(2)
self.cli.execute('app.root.ids.nav_drawer.set_state("toggle")')
time.sleep(1)
self.cli.click_on('//NavigationItem[1]')
time.sleep(1)
self.cli.click_on('//Inbox/ComposerButton[0]/MDFloatingActionButton[0]')
time.sleep(3)
self.cli.click_on('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[0]/MyMDTextField[0]')
time.sleep(3)
self.cli.click_on('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[1]/MyTextInput[0]')
time.sleep(3)
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[1]/MyTextInput[0]', "text", "second add")
time.sleep(3)
self.cli.click_on('//DropDownWidget/ScrollView[0]/BoxLayout[0]/MyMDTextField[0]')
time.sleep(4)
self.cli.click_on('//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/TextInput[0]')
time.sleep(4)
self.cli.click_on('//MDIconButton[2]')
time.sleep(3)
self.cli.click_on('//MDFlatButton[0]')
time.sleep(5)
self.cli.click_on('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[0]/BoxLayout[0]/CustomSpinner[0]/ArrowImg[0]')
time.sleep(2)
self.cli.click_on('//MyTextInput[0]')
time.sleep(3)
self.cli.click_on('//DropDownWidget/ScrollView[0]/BoxLayout[0]/MyMDTextField[0]')
time.sleep(2)
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/MyMDTextField[0]', 'text', 'heyyyyyy')
time.sleep(3)
self.cli.click_on('//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/TextInput[0]')
time.sleep(4)
random_label=""
for char in "how are you this is message body":
random_label += char
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/TextInput[0]','text',random_label)
time.sleep(0.2)
time.sleep(3)
self.cli.click_on('//MDIconButton[2]')
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",data[0])
time.sleep(3)
self.cli.click_on('//MDIconButton[2]')
time.sleep(3)
self.cli.click_on('//MDFlatButton[0]')
time.sleep(3)
def test_sent_multiple_message(self):
"""Sending Second Message From Inbox Screen
for testing the search and delete functionality for two messages on the screen"""
print("=====================Test - Sending Message From Inbox Screen=====================")
time.sleep(3)
self.cli.execute('app.root.ids.nav_drawer.set_state("toggle")')
time.sleep(5)
self.cli.click_on('//NavigationItem[1]')
time.sleep(3)
self.cli.click_on('//Inbox/ComposerButton[0]/MDFloatingActionButton[0]')
time.sleep(3)
self.cli.click_on('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[0]/BoxLayout[0]/CustomSpinner[0]/ArrowImg[0]')
time.sleep(2)
self.cli.click_on('//MyTextInput[0]')
time.sleep(3)
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)
random_label=""
for char in "Hey This Is Second Message Body":
random_label += char
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/TextInput[0]',"text",random_label)
time.sleep(0.2)
time.sleep(2)
self.cli.click_on('//MDIconButton[2]')
time.sleep(5)
self.cli.execute('app.clickNavDrawer()')
time.sleep(3)
self.cli.click_on('//NavigationItem[2]')
time.sleep(3)
def test_show_sent_messgae_list(self):
"""Displaying All the Messages on Sent Screen"""
print("=====================Test - Show Sent Screen Message=====================")
time.sleep(5)
self.cli.execute('app.clickNavDrawer()')
time.sleep(5)
self.cli.click_on('//NavigationItem[0]')
time.sleep(5)
self.cli.click_on('//MySpinnerOption[0]')
time.sleep(6)
self.cli.click_on('//NavigationItem[2]')
time.sleep(2)
def test_search_sent_messages(self):
"""Search Message From a Word Of Subject/Body on Sent Screen"""
print("=====================Test - Search Message On The Sent Screen=====================")
time.sleep(1)
self.cli.click_on('//Sent/BoxLayout[0]/SearchBar[0]/MDTextField[0]')
time.sleep(2)
self.cli.setattr('//Sent/BoxLayout[0]/SearchBar[0]/MDTextField[0]', 'text', 'how')
time.sleep(2)
self.cli.send_keycode('Enter')
time.sleep(5)
self.cli.click_on('//Sent/BoxLayout[0]/SearchBar[0]/MDIconButton[0]')
time.sleep(3)
def test_show_sent_message_body(self):
"""Show A Message From Message Body"""
print("=====================Test - Show A Message From Message Body=====================")
time.sleep(5)
self.cli.click_on('//Carousel[0]//TwoLineAvatarIconListItem[0]')
time.sleep(5)
self.cli.click_on('//MDToolbar/BoxLayout[0]/MDIconButton[0]')
time.sleep(2)
def test_delete_sent_message_body(self):
"""Delete A Message From Message Body"""
print("=====================Test - Delete A Message From Message Body=====================")
time.sleep(2)
self.cli.click_on('//Sent/BoxLayout[0]/BoxLayout[0]/ScrollView[0]/MDList[0]/Carousel[0]//TwoLineAvatarIconListItem[0]')
time.sleep(3)
self.cli.click_on('//MDToolbar/BoxLayout[2]/MDIconButton[0]')
time.sleep(5)
def test_delete_sent_message_from_list(self):
"""Delete A Message From List Of Messages Of Sent Screen"""
print("=====================Test - Delete A Message From List Of Messages=====================")
time.sleep(5)
self.cli.drag('//Sent/BoxLayout[0]/BoxLayout[0]/ScrollView[0]/MDList[0]/Carousel[0]//TwoLineAvatarIconListItem[0]/BoxLayout[0]',
'//Sent/BoxLayout[0]/BoxLayout[0]/ScrollView[0]/MDList[0]/Carousel[0]//TwoLineAvatarIconListItem[0]/BoxLayout[2]', 2)
time.sleep(4)
self.cli.click_on('//Sent/BoxLayout[0]/BoxLayout[0]/ScrollView[0]/MDList[0]/Carousel[0]//Button[0]')
def test_archive_sent_message_from_list(self):
"""Archive A Message From List Of Messages Of Sent Screen"""
print("=====================Test - Archive A Message From List Of Messages=====================")
# Swipe-Arrchive-Sent-Message
time.sleep(4)
self.cli.drag('/NavigationLayout/BoxLayout[1]/FloatLayout[0]/BoxLayout[0]/ScreenManager[0]/Sent[0]/BoxLayout[0]/BoxLayout[0]/ScrollView[0]/MDList[0]/Carousel[0]/RelativeLayout[2]/CustomTwoLineAvatarIconListItem[0]/BoxLayout[0]','/NavigationLayout/BoxLayout[1]/FloatLayout[0]/BoxLayout[0]/ScreenManager[0]/Sent[0]/BoxLayout[0]/BoxLayout[0]/ScrollView[0]/MDList[0]/Carousel[0]/RelativeLayout[0]/Button[0]',1)
time.sleep(2)
self.cli.click_on('/NavigationLayout/BoxLayout[1]/FloatLayout[0]/BoxLayout[0]/ScreenManager[0]/Sent[0]/BoxLayout[0]/BoxLayout[0]/ScrollView[0]/MDList[0]/Carousel[0]/RelativeLayout[1]/Button[0]')
time.sleep(4)
def test_all_sent_method(self):
"""Calling All The Methods Sent Class"""
self.test_show_sent_messgae_list()
self.test_search_sent_messages()
self.test_show_sent_message_body()
self.test_delete_sent_message_body()
self.test_delete_sent_message_from_list()
class Bitmessage_Draft_Screen_Message(TeleniumTestCase):
"""Draft Screen Functionality Testing"""
def runTest(self):
print(self,"-------------Welcome To Kivy Testing Application Fourth Page-------------")
def test_select_draft_message(self):
"""Select A Draft Screen From Navigaion-Drawer-Box Then
Send a drafted message """
print("=====================Test - Select A Draft Screen From Navigaion-Drawer-Box=====================")
# OPEN NAVIGATION-DRAWER
time.sleep(4)
self.cli.execute('app.clickNavDrawer()')
time.sleep(2)
# OPEN INBOX SCREEN
self.cli.click_on('//NavigationItem[1]')
time.sleep(2)
# CLICK ON PLUS ICON BUTTON
self.cli.click_on('//Inbox/ComposerButton[0]/MDFloatingActionButton[0]')
time.sleep(3)
# SELECT - TO ADDRESS
self.cli.click_on('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[0]/BoxLayout[0]/CustomSpinner[0]/ArrowImg[0]')
time.sleep(2)
self.cli.click_on('//MyTextInput[0]')
time.sleep(3)
# ADD FROM MESSAGE
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[1]/BoxLayout[0]/MyTextInput[0]', "text",'BM-2cSsuH1bUWBski8bvdqnK2DivMqQCeQA1J')
time.sleep(3)
# CLICK BACK-BUTTON
self.cli.click_on('//MDToolbar/BoxLayout[0]/MDIconButton[0]')
time.sleep(5)
self.cli.click_on('//Inbox/ComposerButton[0]/MDFloatingActionButton[0]')
time.sleep(3)
# SELECT - TO ADDRESS
self.cli.click_on('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[0]/BoxLayout[0]/CustomSpinner[0]/ArrowImg[0]')
time.sleep(1)
self.cli.click_on('//MyTextInput[0]')
time.sleep(3)
# ADD FROM MESSAGE
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[1]/BoxLayout[0]/MyTextInput[0]', "text",'BM-2cSsuH1bUWBski8bvdqnK2DivMqQCeQA1J')
time.sleep(4)
random_label=""
for char in "Another Draft message":
random_label += char
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/MyMDTextField[0]', 'text', random_label)
time.sleep(0.2)
# CLICK BACK-BUTTON
self.cli.click_on('//MDToolbar/BoxLayout[0]/MDIconButton[0]')
time.sleep(4)
def test_edit_draft_messgae(self):
"""Select A Message From List of Messages Then
make changes and send it."""
print("=====================Test - Edit A Message From Draft Screen=====================")
# OPEN NAVIGATION-DRAWER
self.cli.execute('app.clickNavDrawer()')
time.sleep(4)
# OPEN DRAFT SCREEN
self.cli.click_on('//NavigationItem[3]')
time.sleep(4)
# SHOW DRAFT MESSAGE AND SELECT FIRST MESSAGE
self.cli.click_on('//Carousel[0]//TwoLineAvatarIconListItem[0]')
time.sleep(3)
# CLICK EDIT BUTTON
self.cli.click_on('//MDToolbar/BoxLayout[2]/MDIconButton[0]')
time.sleep(5)
random_label=""
for char in "Hey,This is draft Message Body":
random_label += char
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/TextInput[0]', 'text', random_label)
time.sleep(0.2)
time.sleep(3)
self.cli.click_on('//MDIconButton[2]')
time.sleep(5)
def test_delete_draft_message(self):
"""Delete A Message From List of Messages"""
print("=====================Test - Delete A Message From List of Messages=====================")
time.sleep(5)
# self.cli.execute('app.root.ids.nav_drawer.set_state("toggle")')
self.cli.execute('app.clickNavDrawer()')
time.sleep(4)
self.cli.click_on('//NavigationItem[3]')
time.sleep(5)
self.cli.click_on('//Carousel[0]//TwoLineAvatarIconListItem[0]')
time.sleep(5)
self.cli.click_on('//MDToolbar/BoxLayout[2]/MDIconButton[1]')
time.sleep(2)
def test_all_draft_method(self):
"""Calling All The Methods Draft Class"""
self.test_select_draft_message()
self.test_edit_draft_messgae()
self.test_delete_draft_message()
class Bitmessage_AllMail_Screen_Message(TeleniumTestCase):
"""AllMail Screen Functionality Testing"""
def runTest(self):
print(self,"-------------Welcome To Kivy Testing Application Sixth Page-------------")
def test_select_all_mails(self):
"""Show All Messages on Mail Screen/Window"""
print("=====================Test -Show Messages Of Mail Screen=====================")
time.sleep(5)
self.cli.execute('app.clickNavDrawer()')
time.sleep(4)
self.cli.click_on('//NavigationItem[5]')
time.sleep(4)
def test_delete_message_from_draft(self):
"""Delete Message From Message body of Mail Screen/Window"""
print("=====================Test -Delete Messages Of Mail Screen=====================")
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]')
time.sleep(3)
class Bitmessage_Trash_Screen_Message(TeleniumTestCase):
"""Trash Screen Functionality Testing"""
def runTest(self):
print(self,"-------------Welcome To Kivy Testing Application Fifth Page-------------")
def test_delete_trash_message(self):
"""Delete Message From List of Message Permanently Of Trash Screen/Window"""
print("=====================Test -Delete Messages Of Trash Screen=====================")
time.sleep(6)
self.cli.execute('app.clickNavDrawer()')
time.sleep(4)
self.cli.click_on('//NavigationItem[4]')
time.sleep(4)
self.cli.drag('//Trash/BoxLayout[0]/BoxLayout[0]/ScrollView[0]/MDList[0]/Carousel[0]//TwoLineAvatarIconListItem[0]/BoxLayout[0]',
'//Trash/BoxLayout[0]/BoxLayout[0]/ScrollView[0]/MDList[0]/Carousel[0]//TwoLineAvatarIconListItem[0]/BoxLayout[2]', 2)
time.sleep(4)
self.cli.click_on('//Trash/BoxLayout[0]/BoxLayout[0]/ScrollView[0]/MDList[0]/Carousel[0]//Button[0]')
time.sleep(2)
self.cli.click_on('//MDDialog/MDCard[0]/AnchorLayout[0]/MDBoxLayout[0]/MDFlatButton[0]')
time.sleep(4)
class Bitmessage_AddressBook_Screen_Message(TeleniumTestCase):
"""AddressBook Screen Functionality Testing"""
def runTest(self):
print(self,"-------------Welcome To Kivy Testing Application Seven Page-------------")
def test_save_address(self):
"""Save Address On Address Book Screen/Window"""
print("=====================Test -Save Address In Address Book=====================")
time.sleep(6)
self.cli.execute('app.clickNavDrawer()')
time.sleep(4)
self.cli.drag("//NavigationItem[@text=\"Sent\"]","//NavigationItem[@text=\"Inbox\"]",1)
time.sleep(3)
self.cli.click_on('//NavigationItem[6]')
time.sleep(4)
self.cli.execute('app.addingtoaddressbook()')
time.sleep(3)
self.cli.click_on('//GrashofPopup/BoxLayout[0]/MDTextField[0]')
time.sleep(4)
self.cli.click_on('//GrashofPopup/BoxLayout[0]/MDTextField[1]')
time.sleep(4)
self.cli.click_on('//MDRaisedButton[0]')
time.sleep(4)
self.cli.click_on('//GrashofPopup/BoxLayout[0]/MDTextField[0]')
time.sleep(3)
self.cli.setattr('//GrashofPopup/BoxLayout[0]/MDTextField[0]','text','peter')
time.sleep(3)
self.cli.click_on('//MDRaisedButton[0]')
time.sleep(4)
self.cli.click_on('//GrashofPopup/BoxLayout[0]/MDTextField[1]')
time.sleep(3)
self.cli.setattr('//GrashofPopup/BoxLayout[0]/MDTextField[1]','text','sectorAppartment')
time.sleep(3)
self.cli.click_on('//MDRaisedButton[0]')
time.sleep(5)
self.cli.click_on('//GrashofPopup/BoxLayout[0]/MDTextField[1]')
time.sleep(3)
self.cli.setattr('//GrashofPopup/BoxLayout[0]/MDTextField[1]','text',data[0])
time.sleep(3)
self.cli.setattr('//GrashofPopup/BoxLayout[0]/MDTextField[1]','text','')
time.sleep(3)
self.cli.click_on('//MDRaisedButton[0]')
time.sleep(4)
self.cli.setattr('//GrashofPopup/BoxLayout[0]/MDTextField[1]','text','BM-2cX78L9CZpb6GGC3rRVizYiUBwHELMLybd')
time.sleep(3)
self.cli.click_on('//MDRaisedButton[0]')
time.sleep(4)
def test_cancel_address(self):
"""Cancel Address"""
print("=====================Test -Cancel Address=====================")
time.sleep(3)
self.cli.execute('app.addingtoaddressbook()')
time.sleep(3)
self.cli.setattr('//GrashofPopup/BoxLayout[0]/MDTextField[0]','text','prachi')
time.sleep(3)
self.cli.setattr('//GrashofPopup/BoxLayout[0]/MDTextField[1]','text',data[0])
time.sleep(3)
self.cli.click_on('//MDRaisedButton[1]')
def test_send_message_to_addressbook(self):
"""Directly Send Message To The User"""
print("=====================Test -Directly Send Message To The User=====================")
time.sleep(4)
self.cli.click_on('//AddressBook/BoxLayout[0]/BoxLayout[0]/ScrollView[0]/MDList[0]/Carousel[0]')
time.sleep(3)
self.cli.click_on('//MDRaisedButton[0]')
time.sleep(3)
self.cli.click_on('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[0]/BoxLayout[0]/CustomSpinner[0]/ArrowImg[0]')
time.sleep(2)
self.cli.click_on('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[1]/BoxLayout[0]/MyTextInput[0]')
time.sleep(3)
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/MyMDTextField[0]', 'text', 'Second')
time.sleep(3)
random_label=""
for char in "Hey This is Message From Address Book":
random_label += char
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/TextInput[0]', 'text', random_label)
time.sleep(0.2)
self.cli.click_on('//MDIconButton[2]')
time.sleep(2)
def test_delete_address_from_address_contact(self):
"""Delete Address From Address Book"""
print("=====================Test -Delete Address From Address Book=====================")
time.sleep(3)
self.cli.execute('app.clickNavDrawer()')
time.sleep(3)
self.cli.click_on('//NavigationItem[6]')
time.sleep(3)
self.cli.drag('//AddressBook/BoxLayout[0]/BoxLayout[0]/ScrollView[0]/MDList[0]/Carousel[0]//TwoLineAvatarIconListItem[0]/BoxLayout[0]',
'//AddressBook/BoxLayout[0]/BoxLayout[0]/ScrollView[0]/MDList[0]/Carousel[0]//TwoLineAvatarIconListItem[0]/BoxLayout[2]', 2)
time.sleep(2)
self.cli.click_on('//AddressBook/BoxLayout[0]/BoxLayout[0]/ScrollView[0]/MDList[0]/Carousel[0]//Button[0]')
def test_all_address_book_method(self):
self.test_save_address()
self.test_cancel_address()
self.test_send_message_to_addressbook()
self.test_delete_address_from_address_contact()
class Bitmessage_Setting_Screen(TeleniumTestCase):
"""Setting Screen Functionality Testing"""
def runTest(self):
print(self,"-------------Welcome To Kivy Testing Application Eight Page-------------")
def test_setting(self):
"""Show Setting Screen"""
print("=====================Test -Show Setting Screen=====================")
time.sleep(4)
self.cli.execute('app.clickNavDrawer()')
time.sleep(3)
self.cli.drag("//NavigationItem[@text=\"Sent\"]","//NavigationItem[@text=\"Inbox\"]",1)
time.sleep(3)
self.cli.click_on('//NavigationItem[7]')
time.sleep(2)
class Bitmessage_MyAddress_Screen_Message(TeleniumTestCase):
"""MyAddress Screen Functionality Testing"""
def runTest(self):
print(self,"-------------Welcome To Kivy Testing Application Ninth Page-------------")
def test_select_myaddress_list(self):
"""Select Address From List of Address"""
print("=====================Test -Select Address From List of Address=====================")
time.sleep(4)
self.cli.execute('app.clickNavDrawer()')
time.sleep(3)
self.cli.drag("//NavigationItem[@text=\"Sent\"]","//NavigationItem[@text=\"Inbox\"]",1)
time.sleep(3)
self.cli.click_on('//NavigationItem[11]')
time.sleep(4)
def test_show_Qrcode(self):
"""Show the Qr code of selected address"""
print("=====================Test -Show QR code of selected address=====================")
time.sleep(4)
self.cli.click_on('//MyAddress/BoxLayout[0]/FloatLayout[0]/MDScrollViewRefreshLayout[0]/MDList[0]/CustomTwoLineAvatarIconListItem[0]')
time.sleep(3)
self.cli.click_on('//MyaddDetailPopup/BoxLayout[1]/MDRaisedButton[1]/MDLabel[0]')
time.sleep(3)
self.cli.click_on('//MDToolbar/BoxLayout[0]/MDIconButton[0]')
time.sleep(3)
def test_send_message_from(self):
"""Send Message From Send Message From Button"""
print("=====================Test -Send Message From Send Message From Button=====================")
time.sleep(4)
self.cli.click_on('//MyAddress/BoxLayout[0]/FloatLayout[0]/MDScrollViewRefreshLayout[0]/MDList[0]/CustomTwoLineAvatarIconListItem[0]')
time.sleep(4)
self.cli.click_on('//MyaddDetailPopup/BoxLayout[1]/MDRaisedButton[0]/MDLabel[0]')
time.sleep(3)
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[1]/BoxLayout[0]/MyTextInput', "text", data[1])
time.sleep(3)
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/MyMDTextField[0]', 'text', 'Hey')
time.sleep(3)
random_label=""
for char in "Hey,i am sending message directly from MyAddress book":
random_label += char
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/ScrollView[0]/TextInput[0]', 'text', random_label)
time.sleep(0.2)
time.sleep(2)
self.cli.click_on('//MDIconButton[2]')
time.sleep(2)
class Bitmessage_SubscriptionPayment_Screen(TeleniumTestCase):
"""SubscriptionPayment Screen Functionality Testing"""
def runTest(self):
print(self,"-------------Welcome To Kivy Testing Application Tenth Page-------------")
def test_select_subscripton(self):
"""Select Subscripton From List of Subscriptons"""
print("=====================Test -Select Subscripton From List of Subscriptons=====================")
time.sleep(4)
self.cli.execute('app.clickNavDrawer()')
time.sleep(3)
self.cli.drag("//NavigationItem[@text=\"Sent\"]","//NavigationItem[@text=\"Inbox\"]",1)
time.sleep(3)
self.cli.click_on('//NavigationItem[8]')
time.sleep(3)
self.cli.drag('//Payment/BoxLayout[0]/ScrollView[0]/BoxLayout[0]/ProductCategoryLayout[0]/ProductLayout[1]',
'//Payment/BoxLayout[0]/ScrollView[0]/BoxLayout[0]/ProductCategoryLayout[0]/ProductLayout[0]', 1)
time.sleep(2)
self.cli.click_on('//MDRaisedButton[3]')
time.sleep(2)
self.cli.click_on('//ListItemWithLabel[0]')
time.sleep(2)
self.cli.click_on('//MDRaisedButton[3]')
time.sleep(2)
class Bitmessage_NetwrokStatus_Screen(TeleniumTestCase):
"""NetwrokStatus Screen Functionality Testing"""
def runTest(self):
print(self,"-------------Welcome To Kivy Testing Application Twelth Page-------------")
def test_total_selection(self):
"""Show NetwrokStatus"""
print("=====================Test -Show NetwrokStatus=====================")
time.sleep(4)
self.cli.execute('app.clickNavDrawer()')
time.sleep(3)
self.cli.drag("//NavigationItem[@text=\"Sent\"]","//NavigationItem[@text=\"Inbox\"]",1)
time.sleep(3)
self.cli.click_on('//NavigationItem[10]')
time.sleep(4)
self.cli.click_on('//NetworkStat/MDTabs[0]/MDTabsBar[0]/MDTabsScrollView[0]/MDGridLayout[0]/MDTabsLabel[1]')
time.sleep(4)

View File

@ -33,6 +33,7 @@ def loadConfig():
"""Load the config"""
config = BMConfigParser()
print('state.appdata//////////////////////////////////................(36)', state.appdata)
if state.appdata:
config.read(state.appdata + 'keys.dat')
# state.appdata must have been specified as a startup option.

34
src/tests/common.py Normal file
View File

@ -0,0 +1,34 @@
import os
import sys
import time
import unittest
_files = (
'keys.dat', 'debug.log', 'messages.dat', 'knownnodes.dat',
'.api_started', 'unittest.lock'
)
def cleanup(home=None, files=_files):
"""Cleanup application files"""
if not home:
import state
home = state.appdata
for pfile in files:
try:
os.remove(os.path.join(home, pfile))
except OSError:
pass
def skip_python3():
"""Raise unittest.SkipTest() if detected python3"""
# if sys.hexversion >= 0x3000000:
# raise unittest.SkipTest('Module is not ported to python3')
def put_signal_file(path, filename):
"""Creates file, presence of which is a signal about some event."""
with open(os.path.join(path, filename), 'wb') as outfile:
outfile.write(b'%i' % time.time())

View File

@ -5,17 +5,18 @@ Common reusable code for tests and tests for pybitmessage process.
import os
import signal
import subprocess # nosec
import sys
import state
import tempfile
import time
import unittest
import psutil
from .common import cleanup, put_signal_file, skip_python3
def put_signal_file(path, filename):
"""Creates file, presence of which is a signal about some event."""
with open(os.path.join(path, filename), 'wb') as outfile:
outfile.write(str(time.time()))
skip_python3()
class TestProcessProto(unittest.TestCase):
@ -23,24 +24,73 @@ class TestProcessProto(unittest.TestCase):
it starts pybitmessage in setUpClass() and stops it in tearDownClass()
"""
_process_cmd = ['pybitmessage', '-d']
_threads_count = 15
_threads_count_min = 15
_threads_count_max = 16
_threads_names = [
'PyBitmessage',
'addressGenerato',
'singleWorker',
'SQL',
'objectProcessor',
'singleCleaner',
'singleAPI',
'Asyncore',
'ReceiveQueue_0',
'ReceiveQueue_1',
'ReceiveQueue_2',
'Announcer',
'InvBroadcaster',
'AddrBroadcaster',
'Downloader',
'Uploader'
]
_files = (
'keys.dat', 'debug.log', 'messages.dat', 'knownnodes.dat',
'.api_started', 'unittest.lock'
)
home = None
@classmethod
def setUpClass(cls):
"""Setup environment and start pybitmessage"""
cls.home = os.environ['BITMESSAGE_HOME'] = tempfile.gettempdir()
print('setUpClass.........................................(pass)', state.appdata)
# import pdb;pdb.set_trace()
cls.flag = False
if not cls.home:
cls.home = tempfile.gettempdir()
cls._cleanup_files()
os.environ['BITMESSAGE_HOME'] = cls.home
print('os.environ["BITMESSAGE_HOME"]...........................', os.environ['BITMESSAGE_HOME'])
put_signal_file(cls.home, 'unittest.lock')
subprocess.call(cls._process_cmd) # nosec
time.sleep(5)
cls.pid = int(cls._get_readline('singleton.lock'))
cls.process = psutil.Process(cls.pid)
starttime = int(time.time()) - 0.5
cls.process = psutil.Popen(
cls._process_cmd, stderr=subprocess.STDOUT) # nosec
pidfile = os.path.join(cls.home, 'singleton.lock')
for _ in range(10):
time.sleep(1)
try:
pstat = os.stat(pidfile)
if starttime <= pstat.st_mtime and pstat.st_size > 0:
break # the pidfile is suitable
except OSError:
continue
try:
pid = int(cls._get_readline('singleton.lock'))
cls.process = psutil.Process(pid)
time.sleep(5)
except (psutil.NoSuchProcess, TypeError):
cls.flag = True
def setUp(self):
print('setUp.........................................(pass)')
if self.flag:
self.fail("%s is not started ):" % self._process_cmd)
@classmethod
def _get_readline(cls, pfile):
print('_get_readline.........................................(pass)')
pfile = os.path.join(cls.home, pfile)
try:
return open(pfile, 'rb').readline().strip()
@ -49,6 +99,7 @@ class TestProcessProto(unittest.TestCase):
@classmethod
def _stop_process(cls, timeout=5):
print('_stop_process.........................................(pass)')
cls.process.send_signal(signal.SIGTERM)
try:
cls.process.wait(timeout)
@ -56,46 +107,87 @@ class TestProcessProto(unittest.TestCase):
return False
return True
@classmethod
def _kill_process(cls, timeout=5):
print('_kill_process.........................................')
try:
cls.process.send_signal(signal.SIGKILL)
cls.process.wait(timeout)
# Windows or already dead
except (AttributeError, psutil.NoSuchProcess):
return True
# except psutil.TimeoutExpired propagates, it means something is very
# wrong
return True
@classmethod
def _cleanup_files(cls):
for pfile in cls._files:
try:
os.remove(os.path.join(cls.home, pfile))
except OSError:
pass
print('_cleanup_files.........................................(pass)')
cleanup(cls.home, cls._files)
@classmethod
def tearDownClass(cls):
"""Ensures that pybitmessage stopped and removes files"""
print('tearDownClass.........................................(pass)')
try:
if not cls._stop_process():
print(open(os.path.join(cls.home, 'debug.log'), 'rb').read())
cls.process.kill()
if not cls._stop_process(10):
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:
cls._cleanup_files()
def _test_threads(self):
# only count for now
# because of https://github.com/giampaolo/psutil/issues/613
# PyBitmessage
# - addressGenerator
# - singleWorker
# - SQL
# - objectProcessor
# - singleCleaner
# - singleAPI
# - Asyncore
# - ReceiveQueue_0
# - ReceiveQueue_1
# - ReceiveQueue_2
# - Announcer
# - InvBroadcaster
# - AddrBroadcaster
# - Downloader
self.assertEqual(
len(self.process.threads()), self._threads_count)
"""Test number and names of threads"""
# pylint: disable=invalid-name
print('_test_threads.........................................(pass)')
self.longMessage = True
try:
# using ps for posix platforms
# because of https://github.com/giampaolo/psutil/issues/613
thread_names = subprocess.check_output([
"ps", "-L", "-o", "comm=", "--pid",
str(self.process.pid)
]).split()
except: # pylint: disable=bare-except
thread_names = []
running_threads = len(thread_names)
if 0 < running_threads < 30: # adequacy check
extra_threads = []
missing_threads = []
for thread_name in thread_names:
if thread_name not in self._threads_names:
extra_threads.append(thread_name)
for thread_name in self._threads_names:
if thread_name not in thread_names:
missing_threads.append(thread_name)
msg = "Missing threads: {}, Extra threads: {}".format(
",".join(missing_threads), ",".join(extra_threads))
else:
running_threads = self.process.num_threads()
if sys.platform.startswith('win'):
running_threads -= 1 # one extra thread on Windows!
msg = "Unexpected running thread count"
self.assertGreaterEqual(
running_threads,
self._threads_count_min,
msg)
self.assertLessEqual(
running_threads,
self._threads_count_max,
msg)
class TestProcessShutdown(TestProcessProto):
@ -103,15 +195,11 @@ class TestProcessShutdown(TestProcessProto):
def test_shutdown(self):
"""Send to pybitmessage SIGTERM and ensure it stopped"""
# longer wait time because it's not a benchmark
print('test_shutdown.........................................(pass)')
self.assertTrue(
self._stop_process(20),
'%s has not stopped in 20 sec' % ' '.join(self._process_cmd))
@classmethod
def tearDownClass(cls):
"""Special teardown because pybitmessage is already stopped"""
cls._cleanup_files()
class TestProcess(TestProcessProto):
"""A test case for pybitmessage process"""
@ -119,6 +207,21 @@ class TestProcess(TestProcessProto):
"""Check PyBitmessage process name"""
self.assertEqual(self.process.name(), 'PyBitmessage')
@unittest.skipIf(psutil.version_info < (4, 0), 'psutil is too old')
def test_home(self):
"""Ensure BITMESSAGE_HOME is used by process"""
print('test1......................', self.process.environ().get('BITMESSAGE_HOME'))
print('test2......................', self.home)
self.assertEqual(
self.process.environ().get('BITMESSAGE_HOME'), self.home)
def test_listening(self):
"""Check that pybitmessage listens on port 8444"""
for c in self.process.connections():
if c.status == 'LISTEN':
self.assertEqual(c.laddr[1], 8444)
break
def test_files(self):
"""Check existence of PyBitmessage files"""
for pfile in self._files:

View File

@ -0,0 +1,137 @@
"""
Common reusable code for tests and tests for pybitmessage process.
"""
import os
import signal
import subprocess # nosec
import tempfile
import time
import unittest
import psutil
def put_signal_file(path, filename):
"""Creates file, presence of which is a signal about some event."""
# import pdb;pdb.set_trace()
with open(os.path.join(path, filename), 'wb') as outfile:
# outfile.write(str(time.time()))
outfile.write(b'(time.time())')
class TestProcessProto(unittest.TestCase):
"""Test case implementing common logic for external testing:
it starts pybitmessage in setUpClass() and stops it in tearDownClass()
"""
_process_cmd = ['pybitmessage', '-d']
_threads_count = 15
_files = (
'keys.dat', 'debug.log', 'messages.dat', 'knownnodes.dat',
'.api_started', 'unittest.lock'
)
@classmethod
def setUpClass(cls):
"""Setup environment and start pybitmessage"""
import pdb;pdb.set_trace()
cls.home = os.environ['BITMESSAGE_HOME'] = tempfile.gettempdir()
put_signal_file(cls.home, 'unittest.lock')
subprocess.call(cls._process_cmd) # nosec
time.sleep(5)
cls.pid = int(cls._get_readline('singleton.lock'))
cls.process = psutil.Process(cls.pid)
@classmethod
def _get_readline(cls, pfile):
pfile = os.path.join(cls.home, pfile)
try:
return open(pfile, 'rb').readline().strip()
except (OSError, IOError):
pass
@classmethod
def _stop_process(cls, timeout=5):
cls.process.send_signal(signal.SIGTERM)
try:
cls.process.wait(timeout)
except psutil.TimeoutExpired:
return False
return True
@classmethod
def _cleanup_files(cls):
for pfile in cls._files:
try:
os.remove(os.path.join(cls.home, pfile))
except OSError:
pass
@classmethod
def tearDownClass(cls):
"""Ensures that pybitmessage stopped and removes files"""
try:
if not cls._stop_process():
print(open(os.path.join(cls.home, 'debug.log'), 'rb').read())
cls.process.kill()
except psutil.NoSuchProcess:
pass
finally:
cls._cleanup_files()
def _test_threads(self):
# only count for now
# because of https://github.com/giampaolo/psutil/issues/613
# PyBitmessage
# - addressGenerator
# - singleWorker
# - SQL
# - objectProcessor
# - singleCleaner
# - singleAPI
# - Asyncore
# - ReceiveQueue_0
# - ReceiveQueue_1
# - ReceiveQueue_2
# - Announcer
# - InvBroadcaster
# - AddrBroadcaster
# - Downloader
self.assertEqual(
len(self.process.threads()), self._threads_count)
class TestProcessShutdown(TestProcessProto):
"""Separate test case for SIGTERM"""
def test_shutdown(self):
"""Send to pybitmessage SIGTERM and ensure it stopped"""
# longer wait time because it's not a benchmark
self.assertTrue(
self._stop_process(20),
'%s has not stopped in 20 sec' % ' '.join(self._process_cmd))
@classmethod
def tearDownClass(cls):
"""Special teardown because pybitmessage is already stopped"""
cls._cleanup_files()
class TestProcess(TestProcessProto):
"""A test case for pybitmessage process"""
def test_process_name(self):
"""Check PyBitmessage process name"""
self.assertEqual(self.process.name(), 'PyBitmessage')
def test_files(self):
"""Check existence of PyBitmessage files"""
for pfile in self._files:
if pfile.startswith('.'):
continue
self.assertIsNot(
self._get_readline(pfile), None,
'Failed to read file %s' % pfile
)
def test_threads(self):
"""Testing PyBitmessage threads"""
self._test_threads()