def test_DeviceFlasher_run(): """ Ensure the uflash.flash function is called as expected. """ df = DeviceFlasher("path", "script", None) mock_flash = mock.MagicMock() with mock.patch("mu.modes.microbit.uflash", mock_flash): df.run() mock_flash.flash.assert_called_once_with(paths_to_microbits=["path"], python_script="script")
def test_DeviceFlasher_run_fail(): """ Ensure the on_flash_fail signal is emitted if an exception is thrown. """ df = DeviceFlasher(["path"], "script", None) df.on_flash_fail = mock.MagicMock() mock_flash = mock.MagicMock() mock_flash.flash.side_effect = Exception("Boom") with mock.patch("mu.modes.microbit.uflash", mock_flash): df.run() df.on_flash_fail.emit.assert_called_once_with(str(Exception("Boom")))
def test_DeviceFlasher_run(): """ Ensure the uflash.flash function is called as expected. """ df = DeviceFlasher(['path', ], 'script', None) mock_flash = mock.MagicMock() with mock.patch('mu.modes.microbit.uflash', mock_flash): df.run() mock_flash.flash.assert_called_once_with(paths_to_microbits=['path', ], python_script='script', path_to_runtime=None)
def test_DeviceFlasher_run_fail(): """ Ensure the on_flash_fail signal is emitted if an exception is thrown. """ df = DeviceFlasher(['path', ], 'script', None) df.on_flash_fail = mock.MagicMock() mock_flash = mock.MagicMock() mock_flash.flash.side_effect = Exception('Boom') with mock.patch('mu.modes.microbit.uflash', mock_flash): df.run() df.on_flash_fail.emit.assert_called_once_with(str(Exception('Boom')))
def test_DeviceFlasher_init(): """ Ensure the DeviceFlasher thread is set up correctly. """ df = DeviceFlasher("path", "script", None) assert df.path_to_microbit == "path" assert df.python_script == "script"
def test_DeviceFlasher_init(): """ Ensure the DeviceFlasher thread is set up correctly. """ df = DeviceFlasher(['path', ], 'script', None) assert df.paths_to_microbits == ['path', ] assert df.python_script == 'script' assert df.path_to_runtime is None
def test_DeviceFlasher_init(): """ Ensure the DeviceFlasher thread is set up correctly. """ df = DeviceFlasher(["path"], "script", None) assert df.paths_to_microbits == ["path"] assert df.python_script == "script" assert df.path_to_runtime is None