modified test cases

This commit is contained in:
cis 2021-07-09 22:20:31 +05:30
parent f48f43ca3e
commit 1d20859486
No known key found for this signature in database
GPG Key ID: 11DC6F36E8B65B24
7 changed files with 46 additions and 139 deletions

View File

@ -51,3 +51,12 @@ class TeleniumTestProcess(TeleniumTestCase):
cleanup() cleanup()
cls.cli.app_quit() cls.cli.app_quit()
cls.process.kill() cls.process.kill()
def click_on(self, xpath, seconds=0.3):
"""this methos is used for on_click event with time"""
self.cli.click_on(xpath)
self.cli.sleep(seconds)
def drag(self, xpath1, xpath2):
self.cli.drag(xpath1, xpath2, 1)
self.cli.sleep(0.3)

View File

@ -9,13 +9,15 @@ class SettingScreen(TeleniumTestProcess):
print("=====================Test -Show Setting Screen=====================") print("=====================Test -Show Setting Screen=====================")
self.cli.sleep(3) self.cli.sleep(3)
# this is for opening Nav drawer # this is for opening Nav drawer
self.cli.click_on('//MDActionTopAppBarButton[@icon=\"menu\"]') self.click_on('//MDActionTopAppBarButton[@icon=\"menu\"]')
self.cli.sleep(3) # checking state of Nav drawer
self.assertEqual(self.cli.getattr('//MDNavigationDrawer', 'state'), 'open')
# this is for scrolling Nav drawer # this is for scrolling Nav drawer
self.cli.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]", 1) self.drag("//NavigationItem[@text=\"Sent\"]", "//NavigationItem[@text=\"Inbox\"]")
self.cli.sleep(3) # assert for checking scroll funcation
scroll_distance = self.cli.getattr('//ContentNavigationDrawer//ScrollView[0]', 'scroll_y')
self.assertLessEqual(scroll_distance, -0.0)
# this is for opening setting screen # this is for opening setting screen
self.cli.click_on('//NavigationItem[@text=\"Settings\"]') self.click_on('//NavigationItem[@text=\"Settings\"]')
self.cli.sleep(2)
# Checking current screen # Checking current screen
self.assertExists("//Setting[@name~=\"set\"]", timeout=2) self.assertExists("//Setting[@name~=\"set\"]", timeout=2)

View File

@ -57,7 +57,7 @@ requirements =
# requirements.source.kivy = ../../kivy # requirements.source.kivy = ../../kivy
# (list) Garden requirements # (list) Garden requirements
garden_requirements = qrcode #garden_requirements = qrcode
# (str) Presplash of the application # (str) Presplash of the application
#presplash.filename = %(source.dir)s/data/presplash.png #presplash.filename = %(source.dir)s/data/presplash.png

View File

@ -8,13 +8,28 @@ from bmconfigparser import BMConfigParser
from network.threads import StoppableThread from network.threads import StoppableThread
fake_addresses = [ fake_addresses = {
'BM-2cXDconV3bk6nPwWgBwN7wXaqZoT1bEzGv', 'BM-2cUgQGcTLWAkC6dNsv2Bc8XB3Y1GEesVLV': {
'BM-2cTWjUVedYftZJbnZfs7MWts92v1R35Try', 'privsigningkey': '5KWXwYq1oJMzghUSJaJoWPn8VdeBbhDN8zFot1cBd6ezKKReqBd',
'BM-2cV1UN3er2YVQBcmJaaeYMXvpwBVokJNTo', 'privencryptionkey': '5JaeFJs8iPcQT3N8676r3gHKvJ5mTWXy1VLhGCEDqRs4vpvpxV8'
'BM-2cWVkWk3TyKUscdcn9E7s9hrwpv2ZsBBog', },
'BM-2cW2a5R1KidMGNByqPKn6nJDDnHtazoere' 'BM-2cUd2dm8MVMokruMTcGhhteTpyRZCAMhnA': {
] 'privsigningkey': '5JnJ79nkcwjo4Aj7iG8sFMkzYoQqWfpUjTcitTuFJZ1YKHZz98J',
'privencryptionkey': '5JXgNzTRouFLqSRFJvuHMDHCYPBvTeMPBiHt4Jeb6smNjhUNTYq'
},
'BM-2cWyvL54WytfALrJHZqbsDHca5QkrtByAW': {
'privsigningkey': '5KVE4gLmcfYVicLdgyD4GmnbBTFSnY7Yj2UCuytQqgBBsfwDhpi',
'privencryptionkey': '5JTw48CGm5CP8fyJUJQMq8HQANQMHDHp2ETUe1dgm6EFpT1egD7'
},
'BM-2cTE65PK9Y4AQEkCZbazV86pcQACocnRXd': {
'privsigningkey': '5KCuyReHx9MB4m5hhEyCWcLEXqc8rxhD1T2VWk8CicPFc8B6LaZ',
'privencryptionkey': '5KBRpwXdX3n2tP7f583SbFgfzgs6Jemx7qfYqhdH7B1Vhe2jqY6'
},
'BM-2cX5z1EgmJ87f2oKAwXdv4VQtEVwr2V3BG': {
'privsigningkey': '5K5UK7qED7F1uWCVsehudQrszLyMZxFVnP6vN2VDQAjtn5qnyRK',
'privencryptionkey': '5J5coocoJBX6hy5DFTWKtyEgPmADpSwfQTazMpU7QPeART6oMAu'
}
}
class FakeAddressGenerator(StoppableThread): class FakeAddressGenerator(StoppableThread):
@ -38,16 +53,19 @@ class FakeAddressGenerator(StoppableThread):
streamNumber = 1 streamNumber = 1
try: try:
if len(BMConfigParser().addresses()) > 0: if len(BMConfigParser().addresses()) > 0:
address = fake_addresses[len(BMConfigParser().addresses())] address = list(fake_addresses.keys())[len(BMConfigParser().addresses())]
else: else:
address = fake_addresses[0] address = list(fake_addresses.keys())[0]
label = queueValue[3] label = queueValue[3]
BMConfigParser().add_section(address) BMConfigParser().add_section(address)
BMConfigParser().set(address, 'label', label) BMConfigParser().set(address, 'label', label)
BMConfigParser().set(address, 'enabled', 'true') BMConfigParser().set(address, 'enabled', 'true')
BMConfigParser().set( BMConfigParser().set(
address, 'privencryptionkey', '5KUayt1aPSsNWsxMJnk27kv79wfRE3cWVPYLazyLQc752bXfQP3') address, 'privsigningkey', fake_addresses[address]['privsigningkey'])
BMConfigParser().set(
address, 'privencryptionkey', fake_addresses[address]['privencryptionkey'])
BMConfigParser().save() BMConfigParser().save()
queues.UISignalQueue.put(( queues.UISignalQueue.put((

View File

View File

@ -1,93 +0,0 @@
"""
A thread for creating addresses
"""
# import queues
try:
import queue as Queue
except ImportError:
import Queue
import logging
import random
from pybitmessage import state
import threading
from pybitmessage.bmconfigparser import BMConfigParser
# from network.threads import StoppableThread
fake_addresses = [
'BM-2cXDconV3bk6nPwWgBwN7wXaqZoT1bEzGv',
'BM-2cTWjUVedYftZJbnZfs7MWts92v1R35Try',
'BM-2cV1UN3er2YVQBcmJaaeYMXvpwBVokJNTo',
'BM-2cWVkWk3TyKUscdcn9E7s9hrwpv2ZsBBog',
'BM-2cW2a5R1KidMGNByqPKn6nJDDnHtazoere'
]
UISignalQueue = Queue.Queue()
addressGeneratorQueue = Queue.Queue()
class StoppableThread(threading.Thread):
"""Base class for application threads with stopThread method"""
name = None
logger = logging.getLogger('default')
def __init__(self, name=None):
if name:
self.name = name
super(StoppableThread, self).__init__(name=self.name)
self.stop = threading.Event()
self._stopped = False
random.seed()
self.logger.info('Init thread %s', self.name)
def stopThread(self):
"""Stop the thread"""
self._stopped = True
self.stop.set()
class FakeAddressGenerator(StoppableThread):
"""A thread for creating fake addresses"""
name = "addressGenerator"
def stopThread(self):
try:
addressGeneratorQueue.put(("stopThread", "data"))
except:
pass
super(FakeAddressGenerator, self).stopThread()
def run(self):
"""
Process the requests for addresses generation
from `.queues.addressGeneratorQueue`
"""
while state.shutdown == 0:
queueValue = addressGeneratorQueue.get()
streamNumber = 1
try:
if len(BMConfigParser().addresses()) > 0:
address = fake_addresses[len(BMConfigParser().addresses())]
else:
address = fake_addresses[0]
label = queueValue[3]
BMConfigParser().add_section(address)
BMConfigParser().set(address, 'label', label)
BMConfigParser().set(address, 'enabled', 'true')
BMConfigParser().set(
address, 'privencryptionkey', '5KUayt1aPSsNWsxMJnk27kv79wfRE3cWVPYLazyLQc752bXfQP3')
BMConfigParser().save()
UISignalQueue.put((
'updateStatusBar', ""
))
UISignalQueue.put(('writeNewAddressToTable', (
label, address, streamNumber)))
addressGeneratorQueue.task_done()
except IndexError:
self.logger.error(
'Program error: you can only create 5 fake addresses')

View File

@ -1,29 +0,0 @@
"""This module is for thread start."""
from pybitmessage import state
from pybitmessage.bitmessagekivy.mpybit import NavigateApp
from class_addressGenerator import FakeAddressGenerator
# from class_sqlThread import sqlThread
def main():
"""main method for starting threads"""
if state.enableObjProc:
# Start the address generation thread
addressGeneratorThread = FakeAddressGenerator()
# 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()
if __name__ == '__main__':
main()