예제 #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")
예제 #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")))
예제 #3
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)
예제 #4
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')))
예제 #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)
예제 #6
0
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"
예제 #7
0
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
예제 #8
0
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