Redesign mocks, fake paths instead of fake class
This commit is contained in:
parent
3aa6473b7d
commit
69cb31d09e
|
@ -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():
|
||||
|
|
0
src/tests/mock/pybitmessage/__init__.py
Normal file
0
src/tests/mock/pybitmessage/__init__.py
Normal file
1
src/tests/mock/pybitmessage/bitmessagekivy
Symbolic link
1
src/tests/mock/pybitmessage/bitmessagekivy
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../../bitmessagekivy
|
|
@ -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())
|
|
@ -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.
|
|
@ -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):
|
||||
|
|
@ -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.
|
0
src/tests/mock/pybitmessage/state.py
Normal file
0
src/tests/mock/pybitmessage/state.py
Normal file
Reference in New Issue
Block a user