Beispiel #1
0
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")
Beispiel #2
0
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")))
Beispiel #3
0
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')))
Beispiel #4
0
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)
Beispiel #5
0
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)