removed the main method and made it work like unit test cases
This commit is contained in:
parent
29bf54905c
commit
35243cc08c
17
src/bitmessagekivy/tests/common.py
Normal file
17
src/bitmessagekivy/tests/common.py
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
|
def make_ordered_test():
|
||||||
|
order = {}
|
||||||
|
|
||||||
|
def ordered(f):
|
||||||
|
order[f.__name__] = len(order)
|
||||||
|
return f
|
||||||
|
|
||||||
|
def compare(a, b):
|
||||||
|
return [1, -1][order[a] < order[b]]
|
||||||
|
|
||||||
|
return ordered, compare
|
||||||
|
|
||||||
|
ordered, compare = make_ordered_test()
|
||||||
|
unittest.defaultTestLoader.sortTestMethodsUsing = compare
|
|
@ -1,35 +0,0 @@
|
||||||
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))
|
|
||||||
print(__file__,'.........................................(clean)', 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())
|
|
|
@ -1,9 +1,9 @@
|
||||||
import os
|
import os, signal
|
||||||
import psutil
|
import psutil
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
from telenium.tests import TeleniumTestCase
|
from telenium.tests import TeleniumTestCase
|
||||||
from bitmessagekivy.tests.test_process_data import TestProcessProto
|
from threads import addressGenerator, sqlThread
|
||||||
|
|
||||||
|
|
||||||
_files = (
|
_files = (
|
||||||
|
@ -26,7 +26,7 @@ def cleanup(home=None, files=_files):
|
||||||
os.remove(os.path.join(home, pfile))
|
os.remove(os.path.join(home, pfile))
|
||||||
print(__file__,'.........................................(clean)', pfile)
|
print(__file__,'.........................................(clean)', pfile)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('error............................................')
|
# print('error............................................')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,45 +40,46 @@ def set_temp_data():
|
||||||
|
|
||||||
class TeleniumTestProcess(TeleniumTestCase):
|
class TeleniumTestProcess(TeleniumTestCase):
|
||||||
"""Setting Screen Functionality Testing"""
|
"""Setting Screen Functionality Testing"""
|
||||||
cmd_entrypoint = ['/home/cis/py3porting/Chatroom/PyBitmessage/src/main.py']
|
cmd_entrypoint = ['/home/cis/py3porting/Chatroom/PyBitmessage/src/main_mock_test.py']
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls, is_login_screen=None):
|
def setUpClass(cls):
|
||||||
print('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', is_login_screen)
|
print('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', __file__)
|
||||||
os.environ["BITMESSAGE_HOME"] = tempfile.gettempdir()
|
os.environ["BITMESSAGE_HOME"] = tempfile.gettempdir()
|
||||||
if is_login_screen:
|
set_temp_data()
|
||||||
cleanup()
|
|
||||||
else:
|
|
||||||
set_temp_data()
|
|
||||||
super(TeleniumTestProcess, cls).setUpClass()
|
super(TeleniumTestProcess, cls).setUpClass()
|
||||||
|
|
||||||
# @classmethod
|
@classmethod
|
||||||
# def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
# """Ensures that pybitmessage stopped and removes files"""
|
"""Ensures that pybitmessage stopped and removes files"""
|
||||||
# print('tearDownClass.........................................(pass)')
|
# super(TeleniumTestProcess, cls).tearDownClass()
|
||||||
# try:
|
print('tearDownClass.........................................(pass)', os.getpid())
|
||||||
# if not cls._stop_process(1):
|
cleanup()
|
||||||
# processes = cls.process.children(recursive=True)
|
pid = os.getpid()
|
||||||
# processes.append(cls.process)
|
os.kill(int(pid), signal.SIGKILL)
|
||||||
# for p in processes:
|
# import pdb;pdb.set_trace()
|
||||||
# try:
|
|
||||||
# p.kill()
|
|
||||||
# except psutil.NoSuchProcess:
|
|
||||||
# pass
|
|
||||||
# except psutil.NoSuchProcess:
|
|
||||||
# pass
|
|
||||||
# finally:
|
|
||||||
# # import pdb;pdb.set_trace()
|
|
||||||
# cleanup()
|
|
||||||
# # cls._cleanup_files()
|
|
||||||
|
|
||||||
# @classmethod
|
# # os.kill()
|
||||||
# def _stop_process(cls, timeout=5):
|
# # import psutil
|
||||||
# print('_stop_process.........................................(pass)')
|
# # cnt = 0
|
||||||
# import signal
|
# # # print('total count=========================================', len(psutil.process_iter()))
|
||||||
# cls.process.send_signal(signal.SIGTERM)
|
# # for proc in psutil.process_iter():
|
||||||
# try:
|
# # print('line...................................62', proc.name(), proc.pid)
|
||||||
# cls.process.wait(timeout)
|
# # cnt = cnt +1
|
||||||
# except psutil.TimeoutExpired:
|
# # if proc.name() == 'python':
|
||||||
# return False
|
# # print('line........................69', proc.pid)
|
||||||
# return True
|
# # # os.kill(int(pid), signal.SIGKILL)
|
||||||
|
# # print('total cnt.............................', cnt)
|
||||||
|
# # # cleanup()
|
||||||
|
# # proc.kill()
|
||||||
|
# # # os.kill(int(proc.pid), signal.SIGKILL)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUp(self):
|
||||||
|
# self.widget = Widget('The widget')
|
||||||
|
print('&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&7setup')
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDown(self):
|
||||||
|
print('###############################################tearDown')
|
||||||
|
# self.widget.dispose()
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
import time
|
import time
|
||||||
from bitmessagekivy.tests.telenium_process import TeleniumTestProcess
|
from bitmessagekivy.tests.telenium_process import TeleniumTestProcess
|
||||||
|
from bmconfigparser import BMConfigParser
|
||||||
|
from .common import ordered
|
||||||
|
|
||||||
|
data = BMConfigParser().addresses()
|
||||||
|
|
||||||
|
|
||||||
class AddressBook(TeleniumTestProcess):
|
class AddressBook(TeleniumTestProcess):
|
||||||
"""AddressBook Screen Functionality Testing"""
|
"""AddressBook Screen Functionality Testing"""
|
||||||
|
|
||||||
|
@ordered
|
||||||
def test_save_address(self):
|
def test_save_address(self):
|
||||||
"""Save Address On Address Book Screen/Window"""
|
"""Save Address On Address Book Screen/Window"""
|
||||||
print("=====================Test -Save Address In Address Book=====================")
|
print("=====================Test -Save Address In Address Book=====================")
|
||||||
|
@ -48,6 +53,7 @@ class AddressBook(TeleniumTestProcess):
|
||||||
self.cli.click_on('//MDRaisedButton[0]')
|
self.cli.click_on('//MDRaisedButton[0]')
|
||||||
time.sleep(4)
|
time.sleep(4)
|
||||||
|
|
||||||
|
@ordered
|
||||||
def test_cancel_address(self):
|
def test_cancel_address(self):
|
||||||
"""Cancel Address"""
|
"""Cancel Address"""
|
||||||
print("=====================Test -Cancel Address=====================")
|
print("=====================Test -Cancel Address=====================")
|
||||||
|
@ -60,6 +66,7 @@ class AddressBook(TeleniumTestProcess):
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
self.cli.click_on('//MDRaisedButton[1]')
|
self.cli.click_on('//MDRaisedButton[1]')
|
||||||
|
|
||||||
|
@ordered
|
||||||
def test_send_message_to_addressbook(self):
|
def test_send_message_to_addressbook(self):
|
||||||
"""Directly Send Message To The User"""
|
"""Directly Send Message To The User"""
|
||||||
print("=====================Test -Directly Send Message To The User=====================")
|
print("=====================Test -Directly Send Message To The User=====================")
|
||||||
|
@ -82,6 +89,7 @@ class AddressBook(TeleniumTestProcess):
|
||||||
self.cli.click_on('//MDIconButton[2]')
|
self.cli.click_on('//MDIconButton[2]')
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
|
@ordered
|
||||||
def test_delete_address_from_address_contact(self):
|
def test_delete_address_from_address_contact(self):
|
||||||
"""Delete Address From Address Book"""
|
"""Delete Address From Address Book"""
|
||||||
print("=====================Test -Delete Address From Address Book=====================")
|
print("=====================Test -Delete Address From Address Book=====================")
|
||||||
|
@ -94,16 +102,3 @@ class AddressBook(TeleniumTestProcess):
|
||||||
'//AddressBook/BoxLayout[0]/BoxLayout[0]/ScrollView[0]/MDList[0]/Carousel[0]//TwoLineAvatarIconListItem[0]/BoxLayout[2]', 2)
|
'//AddressBook/BoxLayout[0]/BoxLayout[0]/ScrollView[0]/MDList[0]/Carousel[0]//TwoLineAvatarIconListItem[0]/BoxLayout[2]', 2)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
self.cli.click_on('//AddressBook/BoxLayout[0]/BoxLayout[0]/ScrollView[0]/MDList[0]/Carousel[0]//Button[0]')
|
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()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
"""Start Application"""
|
|
||||||
obj = AddressBook()
|
|
||||||
obj.setUpClass()
|
|
||||||
obj.test_all_address_book_method()
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
import time
|
import time
|
||||||
from bitmessagekivy.tests.telenium_process import TeleniumTestProcess
|
from bitmessagekivy.tests.telenium_process import TeleniumTestProcess
|
||||||
|
from .common import ordered
|
||||||
|
|
||||||
|
|
||||||
class AllMailMessage(TeleniumTestProcess):
|
class AllMailMessage(TeleniumTestProcess):
|
||||||
"""AllMail Screen Functionality Testing"""
|
"""AllMail Screen Functionality Testing"""
|
||||||
|
|
||||||
|
@ordered
|
||||||
def test_select_all_mails(self):
|
def test_select_all_mails(self):
|
||||||
"""Show All Messages on Mail Screen/Window"""
|
"""Show All Messages on Mail Screen/Window"""
|
||||||
print("=====================Test -Show Messages Of Mail Screen=====================")
|
print("=====================Test -Show Messages Of Mail Screen=====================")
|
||||||
|
@ -13,7 +15,8 @@ class AllMailMessage(TeleniumTestProcess):
|
||||||
time.sleep(4)
|
time.sleep(4)
|
||||||
self.cli.click_on('//NavigationItem[5]')
|
self.cli.click_on('//NavigationItem[5]')
|
||||||
time.sleep(4)
|
time.sleep(4)
|
||||||
|
|
||||||
|
@ordered
|
||||||
def test_delete_message_from_draft(self):
|
def test_delete_message_from_draft(self):
|
||||||
"""Delete Message From Message body of Mail Screen/Window"""
|
"""Delete Message From Message body of Mail Screen/Window"""
|
||||||
print("=====================Test -Delete Messages Of Mail Screen=====================")
|
print("=====================Test -Delete Messages Of Mail Screen=====================")
|
||||||
|
@ -22,11 +25,3 @@ class AllMailMessage(TeleniumTestProcess):
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
self.cli.click_on('//MDToolbar/BoxLayout[2]/MDIconButton[1]')
|
self.cli.click_on('//MDToolbar/BoxLayout[2]/MDIconButton[1]')
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
"""Start Application"""
|
|
||||||
obj = AllMailMessage()
|
|
||||||
obj.setUpClass()
|
|
||||||
obj.test_select_all_mails()
|
|
||||||
obj.test_delete_message_from_draft()
|
|
||||||
|
|
|
@ -1,13 +1,23 @@
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from bitmessagekivy.tests.telenium_process import TeleniumTestProcess, cleanup
|
||||||
|
from .common import ordered
|
||||||
from random import choice
|
from random import choice
|
||||||
from string import ascii_lowercase
|
from string import ascii_lowercase
|
||||||
from bitmessagekivy.tests.telenium_process import TeleniumTestProcess
|
|
||||||
|
|
||||||
|
|
||||||
class CreateRandomAddress(TeleniumTestProcess):
|
class CreateRandomAddress(TeleniumTestProcess):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
print('ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ', __file__)
|
||||||
|
os.environ["BITMESSAGE_HOME"] = tempfile.gettempdir()
|
||||||
|
cleanup()
|
||||||
|
super(TeleniumTestProcess, cls).setUpClass()
|
||||||
|
|
||||||
|
@ordered
|
||||||
def test_login_screen(self):
|
def test_login_screen(self):
|
||||||
"""Clicking on Proceed Button to Proceed to Next Screen."""
|
"""Clicking on Proceed Button to Proceed to Next Screen."""
|
||||||
print("=====================Test - Login Screen=====================")
|
print("=====================Test - Login Screen=====================")
|
||||||
|
@ -15,6 +25,7 @@ class CreateRandomAddress(TeleniumTestProcess):
|
||||||
self.cli.wait_click('//Login/BoxLayout[0]/BoxLayout[0]/ScreenManager[0]/Screen[0]/BoxLayout[0]/AnchorLayout[3]/MDFillRoundFlatIconButton[0]')
|
self.cli.wait_click('//Login/BoxLayout[0]/BoxLayout[0]/ScreenManager[0]/Screen[0]/BoxLayout[0]/AnchorLayout[3]/MDFillRoundFlatIconButton[0]')
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
|
|
||||||
|
@ordered
|
||||||
def test_random_screen(self):
|
def test_random_screen(self):
|
||||||
"""Creating New Adress For New User."""
|
"""Creating New Adress For New User."""
|
||||||
print("=====================Test - Create New Address=====================")
|
print("=====================Test - Create New Address=====================")
|
||||||
|
@ -33,6 +44,7 @@ class CreateRandomAddress(TeleniumTestProcess):
|
||||||
self.cli.wait_click('//RandomBoxlayout/BoxLayout[0]/AnchorLayout[2]/MDFillRoundFlatIconButton[0]')
|
self.cli.wait_click('//RandomBoxlayout/BoxLayout[0]/AnchorLayout[2]/MDFillRoundFlatIconButton[0]')
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
|
@ordered
|
||||||
def test_create_new_address(self):
|
def test_create_new_address(self):
|
||||||
"""Clicking on Navigation Drawer To Open New Address"""
|
"""Clicking on Navigation Drawer To Open New Address"""
|
||||||
print("=====================Test - Create New Address=====================")
|
print("=====================Test - Create New Address=====================")
|
||||||
|
@ -44,7 +56,9 @@ class CreateRandomAddress(TeleniumTestProcess):
|
||||||
self.cli.click_on('//NavigationItem[9]')
|
self.cli.click_on('//NavigationItem[9]')
|
||||||
time.sleep(4)
|
time.sleep(4)
|
||||||
self.cli.wait_click('//Login/BoxLayout[0]/BoxLayout[0]/ScreenManager[0]/Screen[0]/BoxLayout[0]/AnchorLayout[3]/MDFillRoundFlatIconButton[0]')
|
self.cli.wait_click('//Login/BoxLayout[0]/BoxLayout[0]/ScreenManager[0]/Screen[0]/BoxLayout[0]/AnchorLayout[3]/MDFillRoundFlatIconButton[0]')
|
||||||
|
self.test_random_screen()
|
||||||
|
|
||||||
|
@ordered
|
||||||
def test_select_address(self):
|
def test_select_address(self):
|
||||||
"""Select First Address From Drawer-Box"""
|
"""Select First Address From Drawer-Box"""
|
||||||
print("=====================Test - Select First Address From Drawer-Box=======================")
|
print("=====================Test - Select First Address From Drawer-Box=======================")
|
||||||
|
@ -57,15 +71,3 @@ class CreateRandomAddress(TeleniumTestProcess):
|
||||||
self.cli.click_on('//NavigationItem[0]')
|
self.cli.click_on('//NavigationItem[0]')
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
self.cli.click_on('//MySpinnerOption[0]')
|
self.cli.click_on('//MySpinnerOption[0]')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
"""Start Application"""
|
|
||||||
obj = CreateRandomAddress()
|
|
||||||
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()
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
import time
|
import time
|
||||||
from bitmessagekivy.tests.telenium_process import TeleniumTestProcess
|
from bitmessagekivy.tests.telenium_process import TeleniumTestProcess
|
||||||
|
from .common import ordered
|
||||||
|
|
||||||
|
|
||||||
class DraftMessage(TeleniumTestProcess):
|
class DraftMessage(TeleniumTestProcess):
|
||||||
"""Draft Screen Functionality Testing"""
|
"""Draft Screen Functionality Testing"""
|
||||||
|
|
||||||
|
@ordered
|
||||||
def test_select_draft_message(self):
|
def test_select_draft_message(self):
|
||||||
"""Select A Draft Screen From Navigaion-Drawer-Box Then
|
"""Select A Draft Screen From Navigaion-Drawer-Box Then
|
||||||
Send a drafted message """
|
Send a drafted message """
|
||||||
|
@ -49,6 +51,7 @@ class DraftMessage(TeleniumTestProcess):
|
||||||
self.cli.click_on('//MDToolbar/BoxLayout[0]/MDIconButton[0]')
|
self.cli.click_on('//MDToolbar/BoxLayout[0]/MDIconButton[0]')
|
||||||
time.sleep(4)
|
time.sleep(4)
|
||||||
|
|
||||||
|
@ordered
|
||||||
def test_edit_draft_messgae(self):
|
def test_edit_draft_messgae(self):
|
||||||
"""Select A Message From List of Messages Then
|
"""Select A Message From List of Messages Then
|
||||||
make changes and send it."""
|
make changes and send it."""
|
||||||
|
@ -74,6 +77,7 @@ class DraftMessage(TeleniumTestProcess):
|
||||||
self.cli.click_on('//MDIconButton[2]')
|
self.cli.click_on('//MDIconButton[2]')
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
|
@ordered
|
||||||
def test_delete_draft_message(self):
|
def test_delete_draft_message(self):
|
||||||
"""Delete A Message From List of Messages"""
|
"""Delete A Message From List of Messages"""
|
||||||
print("=====================Test - Delete A Message From List of Messages=====================")
|
print("=====================Test - Delete A Message From List of Messages=====================")
|
||||||
|
@ -88,15 +92,15 @@ class DraftMessage(TeleniumTestProcess):
|
||||||
self.cli.click_on('//MDToolbar/BoxLayout[2]/MDIconButton[1]')
|
self.cli.click_on('//MDToolbar/BoxLayout[2]/MDIconButton[1]')
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
def test_all_draft_method(self):
|
# def test_all_draft_method(self):
|
||||||
"""Calling All The Methods Draft Class"""
|
# """Calling All The Methods Draft Class"""
|
||||||
self.test_select_draft_message()
|
# self.test_select_draft_message()
|
||||||
self.test_edit_draft_messgae()
|
# self.test_edit_draft_messgae()
|
||||||
self.test_delete_draft_message()
|
# self.test_delete_draft_message()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
# if __name__ == '__main__':
|
||||||
"""Start Application"""
|
# """Start Application"""
|
||||||
obj = DraftMessage()
|
# obj = DraftMessage()
|
||||||
obj.setUpClass()
|
# obj.setUpClass()
|
||||||
obj.test_all_draft_method()
|
# obj.test_all_draft_method()
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
import time
|
import time
|
||||||
|
from bmconfigparser import BMConfigParser
|
||||||
from bitmessagekivy.tests.telenium_process import TeleniumTestProcess
|
from bitmessagekivy.tests.telenium_process import TeleniumTestProcess
|
||||||
|
from .common import ordered
|
||||||
|
|
||||||
|
data = BMConfigParser().addresses()
|
||||||
|
|
||||||
|
|
||||||
class MyAddressScreen(TeleniumTestProcess):
|
class MyAddressScreen(TeleniumTestProcess):
|
||||||
"""MyAddress Screen Functionality Testing"""
|
"""MyAddress Screen Functionality Testing"""
|
||||||
|
|
||||||
|
@ordered
|
||||||
def test_select_myaddress_list(self):
|
def test_select_myaddress_list(self):
|
||||||
"""Select Address From List of Address"""
|
"""Select Address From List of Address"""
|
||||||
print("=====================Test -Select Address From List of Address=====================")
|
print("=====================Test -Select Address From List of Address=====================")
|
||||||
|
@ -16,6 +21,7 @@ class MyAddressScreen(TeleniumTestProcess):
|
||||||
self.cli.click_on('//NavigationItem[11]')
|
self.cli.click_on('//NavigationItem[11]')
|
||||||
time.sleep(4)
|
time.sleep(4)
|
||||||
|
|
||||||
|
@ordered
|
||||||
def test_show_Qrcode(self):
|
def test_show_Qrcode(self):
|
||||||
"""Show the Qr code of selected address"""
|
"""Show the Qr code of selected address"""
|
||||||
print("=====================Test -Show QR code of selected address=====================")
|
print("=====================Test -Show QR code of selected address=====================")
|
||||||
|
@ -27,6 +33,7 @@ class MyAddressScreen(TeleniumTestProcess):
|
||||||
self.cli.click_on('//MDToolbar/BoxLayout[0]/MDIconButton[0]')
|
self.cli.click_on('//MDToolbar/BoxLayout[0]/MDIconButton[0]')
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
|
|
||||||
|
@ordered
|
||||||
def test_send_message_from(self):
|
def test_send_message_from(self):
|
||||||
"""Send Message From Send Message From Button"""
|
"""Send Message From Send Message From Button"""
|
||||||
print("=====================Test -Send Message From Send Message From Button=====================")
|
print("=====================Test -Send Message From Send Message From Button=====================")
|
||||||
|
@ -47,12 +54,3 @@ class MyAddressScreen(TeleniumTestProcess):
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
self.cli.click_on('//MDIconButton[2]')
|
self.cli.click_on('//MDIconButton[2]')
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
"""Start Application"""
|
|
||||||
obj = MyAddressScreen()
|
|
||||||
obj.setUpClass()
|
|
||||||
obj.test_select_myaddress_list()
|
|
||||||
obj.test_show_Qrcode()
|
|
||||||
obj.test_send_message_from()
|
|
||||||
|
|
|
@ -19,8 +19,8 @@ class NetwrokStatusScreen(TeleniumTestProcess):
|
||||||
time.sleep(4)
|
time.sleep(4)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
# if __name__ == '__main__':
|
||||||
"""Start Application"""
|
# """Start Application"""
|
||||||
obj = NetwrokStatusScreen()
|
# obj = NetwrokStatusScreen()
|
||||||
obj.setUpClass()
|
# obj.setUpClass()
|
||||||
obj.test_network_status()
|
# obj.test_network_status()
|
||||||
|
|
|
@ -26,8 +26,8 @@ class PaymentScreen(TeleniumTestProcess):
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
# if __name__ == '__main__':
|
||||||
"""Start Application"""
|
# """Start Application"""
|
||||||
obj = PaymentScreen()
|
# obj = PaymentScreen()
|
||||||
obj.setUpClass()
|
# obj.setUpClass()
|
||||||
obj.test_select_subscripton()
|
# obj.test_select_subscripton()
|
||||||
|
|
|
@ -6,15 +6,19 @@ import time
|
||||||
|
|
||||||
from bitmessagekivy.tests.telenium_process import TeleniumTestProcess
|
from bitmessagekivy.tests.telenium_process import TeleniumTestProcess
|
||||||
from bmconfigparser import BMConfigParser
|
from bmconfigparser import BMConfigParser
|
||||||
|
from .common import ordered
|
||||||
|
|
||||||
data = []
|
data = BMConfigParser().addresses()
|
||||||
|
|
||||||
class SendMessage(TeleniumTestProcess):
|
class SendMessage(TeleniumTestProcess):
|
||||||
"""Sent Screen Functionality Testing"""
|
"""Sent Screen Functionality Testing"""
|
||||||
|
|
||||||
def test_select_sent(self):
|
@ordered
|
||||||
"""Sending Message From Inbox Screen
|
def test_send_message_to_same_address(self):
|
||||||
opens a pop-up(screen)which send message from sender to reciever"""
|
"""
|
||||||
|
Sending Message From Inbox Screen
|
||||||
|
opens a pop-up(screen)which send message from sender to reciever
|
||||||
|
"""
|
||||||
print("=====================Test - Sending Message From Inbox Screen=====================")
|
print("=====================Test - Sending Message From Inbox Screen=====================")
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
# self.cli.execute('app.root.ids.nav_drawer.set_state("toggle")')
|
# self.cli.execute('app.root.ids.nav_drawer.set_state("toggle")')
|
||||||
|
@ -64,16 +68,19 @@ class SendMessage(TeleniumTestProcess):
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
self.cli.click_on('//MDFlatButton[0]')
|
self.cli.click_on('//MDFlatButton[0]')
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
|
|
||||||
|
@ordered
|
||||||
def test_sent_multiple_message(self):
|
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"""
|
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=====================")
|
print("=====================Test - Sending Message From Inbox Screen=====================")
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
# self.cli.execute('app.root.ids.nav_drawer.set_state("toggle")')
|
# self.cli.execute('app.root.ids.nav_drawer.set_state("toggle")')
|
||||||
self.cli.execute('app.clickNavDrawer()')
|
self.cli.execute('app.clickNavDrawer()')
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
self.cli.click_BMConfigParseron('//NavigationItem[1]')
|
self.cli.click_on('//NavigationItem[1]')
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
self.cli.click_on('//Inbox/ComposerButton[0]/MDFloatingActionButton[0]')
|
self.cli.click_on('//Inbox/ComposerButton[0]/MDFloatingActionButton[0]')
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
|
@ -81,7 +88,6 @@ class SendMessage(TeleniumTestProcess):
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
self.cli.click_on('//MyTextInput[0]')
|
self.cli.click_on('//MyTextInput[0]')
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
data = BMConfigParser().addresses()
|
|
||||||
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[1]/BoxLayout[0]/MyTextInput[0]', "text", data[0])
|
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/BoxLayout[1]/BoxLayout[0]/MyTextInput[0]', "text", data[0])
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/MyMDTextField[0]', 'text', 'Second')
|
self.cli.setattr('//DropDownWidget/ScrollView[0]/BoxLayout[0]/MyMDTextField[0]', 'text', 'Second')
|
||||||
|
@ -98,14 +104,3 @@ class SendMessage(TeleniumTestProcess):
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
self.cli.click_on('//NavigationItem[2]')
|
self.cli.click_on('//NavigationItem[2]')
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
|
|
||||||
|
|
||||||
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()
|
|
||||||
|
|
|
@ -5,9 +5,9 @@ from bitmessagekivy.tests.telenium_process import TeleniumTestProcess
|
||||||
class SettingScreen(TeleniumTestProcess):
|
class SettingScreen(TeleniumTestProcess):
|
||||||
"""Setting Screen Functionality Testing"""
|
"""Setting Screen Functionality Testing"""
|
||||||
|
|
||||||
@classmethod
|
# @classmethod
|
||||||
def setUpClass(cls):
|
# def setUpClass(cls):
|
||||||
super(SettingScreen, cls).setUpClass()
|
# super(SettingScreen, cls).setUpClass()
|
||||||
|
|
||||||
def test_setting_screen(self):
|
def test_setting_screen(self):
|
||||||
"""Show Setting Screen"""
|
"""Show Setting Screen"""
|
||||||
|
@ -20,10 +20,9 @@ class SettingScreen(TeleniumTestProcess):
|
||||||
self.cli.click_on('//NavigationItem[7]')
|
self.cli.click_on('//NavigationItem[7]')
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
|
# if __name__ == '__main__':
|
||||||
if __name__ == '__main__':
|
# """Start Application"""
|
||||||
"""Start Application"""
|
# obj = SettingScreen()
|
||||||
obj = SettingScreen()
|
# obj.setUpClass()
|
||||||
obj.setUpClass()
|
# obj.test_setting_screen()
|
||||||
obj.test_setting_screen()
|
|
||||||
# obj.tearDownClass()
|
# obj.tearDownClass()
|
||||||
|
|
|
@ -1,240 +0,0 @@
|
||||||
"""
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
skip_python3()
|
|
||||||
|
|
||||||
|
|
||||||
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_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"""
|
|
||||||
print('setUpClass.........................................(pass)', state.appdata)
|
|
||||||
# print('os.environ["BITMESSAGE_HOME"](test_process file)57...........................', os.environ['BITMESSAGE_HOME'])
|
|
||||||
# import pdb;pdb.set_trace()
|
|
||||||
print(__file__, 'cls.home..................................', cls.home)
|
|
||||||
cls.flag = False
|
|
||||||
if not cls.home:
|
|
||||||
cls.home = tempfile.gettempdir()
|
|
||||||
cls._cleanup_files()
|
|
||||||
os.environ['BITMESSAGE_HOME'] = cls.home
|
|
||||||
# print("blabla {}".format(__file__))
|
|
||||||
print('os.environ["BITMESSAGE_HOME"](test_process file)65...........................', os.environ['BITMESSAGE_HOME'])
|
|
||||||
put_signal_file(cls.home, 'unittest.lock')
|
|
||||||
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()
|
|
||||||
except (OSError, IOError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def _stop_process(cls, timeout=5):
|
|
||||||
print('_stop_process.........................................(pass)')
|
|
||||||
cls.process.send_signal(signal.SIGTERM)
|
|
||||||
try:
|
|
||||||
cls.process.wait(timeout)
|
|
||||||
except psutil.TimeoutExpired:
|
|
||||||
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):
|
|
||||||
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(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):
|
|
||||||
"""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):
|
|
||||||
"""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
|
|
||||||
print('test_shutdown.........................................(pass)')
|
|
||||||
self.assertTrue(
|
|
||||||
self._stop_process(20),
|
|
||||||
'%s has not stopped in 20 sec' % ' '.join(self._process_cmd))
|
|
||||||
|
|
||||||
|
|
||||||
# class TestProcess(TestProcessProto):
|
|
||||||
# """A test case for pybitmessage process"""
|
|
||||||
# def test_process_name(self):
|
|
||||||
# """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:
|
|
||||||
# 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()
|
|
|
@ -22,8 +22,8 @@ class TrashMessage(TeleniumTestProcess):
|
||||||
time.sleep(4)
|
time.sleep(4)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
# if __name__ == '__main__':
|
||||||
"""Start Application"""
|
# """Start Application"""
|
||||||
obj = TrashMessage()
|
# obj = TrashMessage()
|
||||||
obj.setUpClass()
|
# obj.setUpClass()
|
||||||
obj.test_delete_trash_message()
|
# obj.test_delete_trash_message()
|
||||||
|
|
22
src/bitmessagemain_mock_test.py
Normal file
22
src/bitmessagemain_mock_test.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
import state
|
||||||
|
from bitmessagekivy.mpybit import NavigateApp
|
||||||
|
from threads import addressGenerator, sqlThread
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if state.enableObjProc:
|
||||||
|
print('....................................................line(8)(sqlThread)')
|
||||||
|
|
||||||
|
# Start the address generation thread
|
||||||
|
addressGeneratorThread = addressGenerator()
|
||||||
|
# close the main program even if there are threads left
|
||||||
|
addressGeneratorThread.daemon = True
|
||||||
|
addressGeneratorThread.start()
|
||||||
|
|
||||||
|
sqlLookup = sqlThread()
|
||||||
|
# DON'T close the main program even if there are threads left.
|
||||||
|
# The closeEvent should command this thread to exit gracefully.
|
||||||
|
sqlLookup.daemon = False
|
||||||
|
sqlLookup.start()
|
||||||
|
|
||||||
|
state.kivyapp = NavigateApp()
|
||||||
|
state.kivyapp.run()
|
9
src/main_mock_test.py
Normal file
9
src/main_mock_test.py
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
"""This module is for thread start."""
|
||||||
|
import state
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
state.kivy = True
|
||||||
|
print("Kivy Loading......")
|
||||||
|
# from bitmessagemain import main
|
||||||
|
from bitmessagemain_mock_test import main
|
||||||
|
main()
|
Reference in New Issue
Block a user