コード例 #1
0
    def setUp(self):
        class TestHub(Hub):
            def __init__(self):
                super(TestHub, self).__init__()
                self.testFunctionReplayArg = lambda x: x
                self.testFunctionReplayNone = lambda: None

            def test_function_error(self):
                raise Exception("Error")

        class ClientMock:
            def __init__(self):
                self.writeMessage = flexmock()
                self.close = flexmock()
                pass

        HubsInspector.inspect_implemented_hubs(force_reconstruction=True)
        self.testHubClass = TestHub
        self.testHubInstance = HubsInspector.get_hub_instance(self.testHubClass)

        self.jsonPickler = Pickler(max_depth=3, max_iter=30, make_refs=False)
        self.commEnvironment = CommEnvironment(unprovided_id_template="unprovidedTest__{}")
        self.clientMock = ClientMock()
        self.connectedClient = ConnectedClient(self.commEnvironment, self.clientMock.writeMessage)
        self.connectedClientsHolder = ConnectedClientsHolder(self.testHubInstance)
        self.connectedClientsHolder.all_connected_clients.clear()
コード例 #2
0
    def test_HubCreation_insertsInstanceInHUBs_DICT(self):
        class TestHub1(Hub):
            pass

        HubsInspector.inspect_implemented_hubs(force_reconstruction=True)

        self.assertTrue(HubsInspector.get_hub_instance(TestHub1) in HubsInspector.HUBS_DICT.values())
コード例 #3
0
    def setUp(self):
        global subprocess
        HubsInspector.inspect_implemented_hubs(force_reconstruction=True)
        self.serialMonitorHub = flexmock(HubsInspector.get_hub_instance(SerialMonitorHub))
        """:type : flexmock"""
        self.sender = create_sender_mock()

        self.compileUploaderMock, self.CompileUploaderConstructorMock = create_compiler_uploader_mock()
コード例 #4
0
 def emit(self, record):
     if '\n{"function": "onLoggingMessage"' in record.msg:
         return
     from libs.WSCommunication.Hubs.LoggingHub import LoggingHub
     r = getDecodedMessage(record, self)
     logging_hub = HubsInspector.get_hub_instance(LoggingHub)
     logging_hub.records_buffer.append(r)
     subscribedClients = logging_hub.clients.getSubscribedClients()
     subscribedClients.onLoggingMessage(datetime.now().isoformat(),
                                        r.levelno, r.msg, self.format(r))
コード例 #5
0
ファイル: testCodeHub.py プロジェクト: bq/web2board
    def setUp(self):
        HubsInspector.inspect_implemented_hubs(force_reconstruction=True)
        self.hexFilePath = os.path.join(pm.TEST_SETTINGS_PATH, "CompilerUploader", "hex.hex")
        self.codeHub = HubsInspector.get_hub_instance(CodeHub)
        """:type : CodeHub"""

        self.sender = create_sender_mock()

        self.originalConstruct = CompilerUploader.construct
        self.compileUploaderMock, self.CompileUploaderConstructorMock = create_compiler_uploader_mock()
        self.board = CompilerUploader.DEFAULT_BOARD
コード例 #6
0
    def setUp(self):
        HubsInspector.inspect_implemented_hubs(force_reconstruction=True)
        self.hexFilePath = os.path.join(pm.TEST_SETTINGS_PATH,
                                        "CompilerUploader", "hex.hex")
        self.codeHub = HubsInspector.get_hub_instance(CodeHub)
        """:type : CodeHub"""

        self.sender = create_sender_mock()

        self.originalConstruct = CompilerUploader.construct
        self.compileUploaderMock, self.CompileUploaderConstructorMock = create_compiler_uploader_mock(
        )
        self.board = CompilerUploader.DEFAULT_BOARD
コード例 #7
0
    def setUp(self):
        HubsInspector.inspect_implemented_hubs(force_reconstruction=True)
        Version.read_version_values()
        self.versionsHandlerHub = HubsInspector.get_hub_instance(VersionsHandlerHub)
        """ :type : VersionsHandlerHub"""
        self.libUpdater = self.versionsHandlerHub.lib_updater
        self.updater = self.versionsHandlerHub.w2b_updater
        self.sender = create_sender_mock()

        self.compileUploaderMock, self.CompileUploaderConstructorMock = create_compiler_uploader_mock()
        self.testLibVersion = "1.1.1"

        restore_test_resources()
コード例 #8
0
    def setUp(self):
        class TestHub(Hub):
            def test_method(self, x, _sender, y=1):
                return x, _sender, y

            def test_exception(self):
                raise Exception("MyException")

            def test_no_sender(self, x):
                return x

            def test_replay_unsuccessful(self, x):
                return self._construct_unsuccessful_replay(x)

        self.env_mock = flexmock(debug_mode=True)
        self.testHubClass = TestHub
        HubsInspector.inspect_implemented_hubs(force_reconstruction=True)
        self.testHubInstance = HubsInspector.get_hub_instance(self.testHubClass)
コード例 #9
0
 def __init__(self):
     super(CodeHub, self).__init__()
     self.serial_hub = HubsInspector.get_hub_instance(SerialMonitorHub)
     """ :type : SerialMonitorHub"""
コード例 #10
0
 def test_getHubInstance_returnsAnInstanceOfHubIfExists(self):
     self.assertIsInstance(HubsInspector.get_hub_instance(self.testHubClass), Hub)