Example #1
0
def test_pgzero_stop_game_no_runner():
    """
    If the game is cancelled before the child process is created ensure
    nothing breaks and the UI is reset.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    pm = PyGameZeroMode(editor, view)
    pm.runner = None
    pm.stop_game()
    view.remove_python_runner.assert_called_once_with()
Example #2
0
def test_pgzero_stop_game_no_runner():
    """
    If the game is cancelled before the child process is created ensure
    nothing breaks and the UI is reset.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    pm = PyGameZeroMode(editor, view)
    pm.runner = None
    pm.stop_game()
    view.remove_python_runner.assert_called_once_with()
Example #3
0
def test_pgzero_stop_game():
    """
    Check that the child process is killed, the runner cleaned up and UI
    is reset.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    pm = PyGameZeroMode(editor, view)
    mock_runner = mock.MagicMock()
    pm.runner = mock_runner
    pm.stop_game()
    mock_runner.process.kill.assert_called_once_with()
    mock_runner.process.waitForFinished.assert_called_once_with()
    assert pm.runner is None
    view.remove_python_runner.assert_called_once_with()
Example #4
0
def test_pgzero_stop_game():
    """
    Check that the child process is killed, the runner cleaned up and UI
    is reset.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    pm = PyGameZeroMode(editor, view)
    mock_runner = mock.MagicMock()
    pm.runner = mock_runner
    pm.stop_game()
    mock_runner.process.kill.assert_called_once_with()
    mock_runner.process.waitForFinished.assert_called_once_with()
    assert pm.runner is None
    view.remove_python_runner.assert_called_once_with()
Example #5
0
def test_pgzero_run_game_needs_saving():
    """
    If the file hasn't been saved yet (it's unnamed), prompt the user to save
    it.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    view.current_tab.path = None
    pm = PyGameZeroMode(editor, view)
    pm.stop_game = mock.MagicMock()
    pm.run_game()
    editor.save.assert_called_once_with()
Example #6
0
def test_pgzero_run_game_no_editor():
    """
    If there's no active tab, there can be no runner either.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    view.current_tab = None
    pm = PyGameZeroMode(editor, view)
    pm.stop_game = mock.MagicMock()
    pm.run_game()
    assert pm.runner is None
    pm.stop_game.assert_called_once_with()
Example #7
0
def test_pgzero_run_game_needs_saving():
    """
    If the file hasn't been saved yet (it's unnamed), prompt the user to save
    it.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    view.current_tab.path = None
    pm = PyGameZeroMode(editor, view)
    pm.stop_game = mock.MagicMock()
    pm.run_game()
    editor.save.assert_called_once_with()
Example #8
0
def test_pgzero_run_game_no_editor():
    """
    If there's no active tab, there can be no runner either.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    view.current_tab = None
    pm = PyGameZeroMode(editor, view)
    pm.stop_game = mock.MagicMock()
    pm.run_game()
    assert pm.runner is None
    pm.stop_game.assert_called_once_with()
Example #9
0
def test_pgzero_play_toggle_off():
    """
    Check the handler for clicking play stops the process and reverts the UI
    state.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    pm = PyGameZeroMode(editor, view)
    pm.runner = True
    pm.stop_game = mock.MagicMock()
    pm.play_toggle(None)
    pm.stop_game.assert_called_once_with()
    slot = pm.view.button_bar.slots['play']
    assert slot.setIcon.call_count == 1
    slot.setText.assert_called_once_with('Play')
    slot.setToolTip.assert_called_once_with('Play your Pygame Zero game.')
Example #10
0
def test_pgzero_play_toggle_off():
    """
    Check the handler for clicking play stops the process and reverts the UI
    state.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    pm = PyGameZeroMode(editor, view)
    pm.runner = True
    pm.stop_game = mock.MagicMock()
    pm.play_toggle(None)
    pm.stop_game.assert_called_once_with()
    slot = pm.view.button_bar.slots['play']
    assert slot.setIcon.call_count == 1
    slot.setText.assert_called_once_with('Play')
    slot.setToolTip.assert_called_once_with('Play your Pygame Zero game.')