Redesign mocks, fake paths instead of fake class

This commit is contained in:
John Doe 2021-12-16 15:05:17 +08:00
parent 3aa6473b7d
commit 69cb31d09e
Signed by: PeterSurda
GPG Key ID: 3E47497CF67ABB95
10 changed files with 15 additions and 14 deletions

View File

@ -1,7 +1,7 @@
from class_addressGenerator import FakeAddressGenerator from pybitmessage.class_addressGenerator import addressGenerator
from class_singleWorker import MockSingleWorker from pybitmessage.class_singleWorker import singleWorker
from class_objectProcessor import MockObjectProcessor from pybitmessage.class_objectProcessor import objectProcessor
from inventory import MockInventory from pybitmessage.inventory import Inventory
class MockMain(): class MockMain():
@ -15,26 +15,26 @@ class MockMain():
daemon = config.safeGetBoolean('bitmessagesettings', 'daemon') daemon = config.safeGetBoolean('bitmessagesettings', 'daemon')
# Start the address generation thread # Start the address generation thread
addressGeneratorThread = FakeAddressGenerator() addressGeneratorThread = addressGenerator()
# close the main program even if there are threads left # close the main program even if there are threads left
addressGeneratorThread.daemon = True addressGeneratorThread.daemon = True
addressGeneratorThread.start() addressGeneratorThread.start()
# Start the thread that calculates POWs # Start the thread that calculates POWs
singleWorkerThread = MockSingleWorker() singleWorkerThread = singleWorker()
# close the main program even if there are threads left # close the main program even if there are threads left
singleWorkerThread.daemon = True singleWorkerThread.daemon = True
singleWorkerThread.start() singleWorkerThread.start()
# Start the thread that calculates POWs # Start the thread that calculates POWs
objectProcessorThread = MockObjectProcessor() objectProcessorThread = objectProcessor()
# DON'T close the main program even the thread remains. # DON'T close the main program even the thread remains.
# This thread checks the shutdown variable after processing # This thread checks the shutdown variable after processing
# each object. # each object.
objectProcessorThread.daemon = False objectProcessorThread.daemon = False
objectProcessorThread.start() objectProcessorThread.start()
MockInventory() # init Inventory() # init
def main(): def main():

View File

View File

@ -0,0 +1 @@
../../../bitmessagekivy

View File

@ -60,7 +60,7 @@ class StoppableThread(threading.Thread):
self.stop.set() self.stop.set()
class FakeAddressGenerator(StoppableThread): class addressGenerator(StoppableThread):
"""A thread for creating fake addresses""" """A thread for creating fake addresses"""
name = "addressGenerator" name = "addressGenerator"
address_list = list(fake_addresses.keys()) address_list = list(fake_addresses.keys())

View File

@ -15,7 +15,7 @@ from network import bmproto
logger = logging.getLogger('default') logger = logging.getLogger('default')
class MockObjectProcessor(threading.Thread): class objectProcessor(threading.Thread):
""" """
The objectProcessor thread, of which there is only one, receives network The objectProcessor thread, of which there is only one, receives network
objects (msg, broadcast, pubkey, getpubkey) from the receiveDataThreads. objects (msg, broadcast, pubkey, getpubkey) from the receiveDataThreads.

View File

@ -12,11 +12,11 @@ from network import StoppableThread
from six.moves import queue from six.moves import queue
class MockSingleWorker(StoppableThread): class singleWorker(StoppableThread):
"""Thread for performing PoW""" """Thread for performing PoW"""
def __init__(self): def __init__(self):
super(MockSingleWorker, self).__init__(name="singleWorker") super(singleWorker, self).__init__(name="singleWorker")
proofofwork.init() proofofwork.init()
self.busy = None self.busy = None
@ -27,7 +27,7 @@ class MockSingleWorker(StoppableThread):
queues.workerQueue.put(("stopThread", "data")) queues.workerQueue.put(("stopThread", "data"))
except queue.Full: except queue.Full:
self.logger.error('workerQueue is Full') self.logger.error('workerQueue is Full')
super(MockSingleWorker, self).stopThread() super(singleWorker, self).stopThread()
def run(self): def run(self):

View File

@ -6,7 +6,7 @@ from singleton import Singleton
# pylint: disable=old-style-class,too-few-public-methods # pylint: disable=old-style-class,too-few-public-methods
@Singleton @Singleton
class MockInventory(): class Inventory():
""" """
Inventory singleton class which uses storage backends Inventory singleton class which uses storage backends
to manage the inventory. to manage the inventory.

View File