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

View File

View File

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

View File

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

View File

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

View File

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

View File

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

View File