def test_remove_fs_no_fs(): """ Removing a non-existent file system raises a RuntimeError. """ view = mock.MagicMock() editor = mock.MagicMock() mm = MicrobitMode(editor, view) mm.fs = None with pytest.raises(RuntimeError): mm.remove_fs()
def test_remove_fs_no_fs(): """ Removing a non-existent file system raises a RuntimeError. """ view = mock.MagicMock() editor = mock.MagicMock() mm = MicrobitMode(editor, view) mm.fs = None with pytest.raises(RuntimeError): mm.remove_fs()
def test_remove_fs(): """ Removing the file system results in the expected state. """ view = mock.MagicMock() view.remove_repl = mock.MagicMock() editor = mock.MagicMock() mm = MicrobitMode(editor, view) mm.fs = True mm.remove_fs() assert view.remove_filesystem.call_count == 1 assert mm.fs is None
def test_remove_fs(): """ Removing the file system results in the expected state. """ view = mock.MagicMock() view.remove_repl = mock.MagicMock() editor = mock.MagicMock() mm = MicrobitMode(editor, view) mm.fs = True mm.remove_fs() assert view.remove_filesystem.call_count == 1 assert mm.fs is None
def test_toggle_files_off(): """ If the fs is on, toggle if off. """ view = mock.MagicMock() editor = mock.MagicMock() mm = MicrobitMode(editor, view) mm.remove_fs = mock.MagicMock() mm.repl = None mm.fs = True mm.toggle_files(None) assert mm.remove_fs.call_count == 1
def test_toggle_files_off(): """ If the fs is on, toggle if off. """ view = mock.MagicMock() editor = mock.MagicMock() mm = MicrobitMode(editor, view) mm.remove_fs = mock.MagicMock() mm.repl = None mm.fs = True mm.toggle_files(None) assert mm.remove_fs.call_count == 1
def test_deactivate(): """ Ensure Filesystem pane is hidden, when MicroPython-mode is deactivated. """ view = mock.MagicMock() editor = mock.MagicMock() mm = MicrobitMode(editor, view) mm.remove_fs = mock.MagicMock() mm.activate() mm.fs = True mm.deactivate() mm.remove_fs.assert_called_once_with()
def test_device_changed(microbit): """ Ensure Filesystem pane is reconnected, when the user changes device. """ view = mock.MagicMock() editor = mock.MagicMock() mm = MicrobitMode(editor, view) mm.add_fs = mock.MagicMock() mm.remove_fs = mock.MagicMock() mm.activate() mm.fs = True mm.device_changed(microbit) mm.remove_fs.assert_called_once_with() mm.add_fs.assert_called_once_with()