Пример #1
0
def test_blank_screen():
    """
    Test the blank_screen() method
    """
    # GIVEN: A LibreOfficeServer instance and a bunch of mocks
    server = LibreOfficeServer()
    mocked_control = MagicMock()
    server._control = mocked_control

    # WHEN: blank_screen() is run
    server.blank_screen()

    # THEN: The resume method should have been called
    mocked_control.blankScreen.assert_called_once_with(0)
Пример #2
0
def test_previous_step():
    """
    Test the previous_step() method
    """
    # GIVEN: A LibreOfficeServer instance and a mocked control
    server = LibreOfficeServer()
    mocked_control = MagicMock()
    server._control = mocked_control

    # WHEN: previous_step() is called
    server.previous_step()

    # THEN: The correct call should be made
    mocked_control.gotoPreviousEffect.assert_called_once_with()
Пример #3
0
def test_goto_slide():
    """
    Test the goto_slide() method
    """
    # GIVEN: A LibreOfficeServer instance and some mocks
    server = LibreOfficeServer()
    mocked_control = MagicMock()
    server._control = mocked_control

    # WHEN: goto_slide() is called
    server.goto_slide(1)

    # THEN: The slide number should be correct
    mocked_control.gotoSlideIndex.assert_called_once_with(0)
Пример #4
0
def test_get_slide_number():
    """
    Test the get_slide_number() method
    """
    # GIVEN: A LibreOfficeServer instance and some mocks
    server = LibreOfficeServer()
    mocked_control = MagicMock()
    mocked_control.getCurrentSlideIndex.return_value = 3
    server._control = mocked_control

    # WHEN: get_slide_number() is called
    result = server.get_slide_number()

    # THEN: The slide number should be correct
    assert result == 4
Пример #5
0
def test_start_presentation():
    """
    Test the start_presentation() method when there's a control
    """
    # GIVEN: A LibreOfficeServer instance and some mocks
    server = LibreOfficeServer()
    mocked_control = MagicMock()
    server._control = mocked_control

    # WHEN: start_presentation() is called
    with patch.object(server, 'goto_slide') as mocked_goto_slide:
        server.start_presentation()

    # THEN: The control should have been activated and the first slide selected
    mocked_control.activate.assert_called_once_with()
    mocked_goto_slide.assert_called_once_with(1)
Пример #6
0
def test_stop_presentation():
    """
    Test the stop_presentation() method
    """
    # GIVEN: A LibreOfficeServer instance and a mocked presentation
    server = LibreOfficeServer()
    mocked_presentation = MagicMock()
    mocked_control = MagicMock()
    server._presentation = mocked_presentation
    server._control = mocked_control

    # WHEN: stop_presentation() is called
    server.stop_presentation()

    # THEN: The presentation is ended and the control is removed
    mocked_presentation.end.assert_called_once_with()
    assert server._control is None
Пример #7
0
def test_next_step(mocked_sleep):
    """
    Test the next_step() method when paused
    """
    # GIVEN: A LibreOfficeServer instance and a mocked control
    server = LibreOfficeServer()
    mocked_control = MagicMock()
    server._control = mocked_control
    mocked_control.isPaused.side_effect = [True, True]

    # WHEN: next_step() is called
    server.next_step()

    # THEN: The correct call should be made
    mocked_control.gotoNextEffect.assert_called_once_with()
    mocked_sleep.assert_called_once_with(0.1)
    assert mocked_control.isPaused.call_count == 1
    assert mocked_control.gotoPreviousEffect.call_count == 0
Пример #8
0
def test_is_blank_control_is_running():
    """
    Test the is_blank() method when the control is running
    """
    # GIVEN: A LibreOfficeServer instance and a bunch of mocks
    server = LibreOfficeServer()
    mocked_control = MagicMock()
    server._control = mocked_control
    mocked_control.isRunning.return_value = True
    mocked_control.isPaused.return_value = True

    # WHEN: is_blank() is called
    result = server.is_blank()

    # THEN: It should have returned False
    assert result is True
    mocked_control.isRunning.assert_called_once_with()
    mocked_control.isPaused.assert_called_once_with()
Пример #9
0
def test_is_active():
    """
    Test is_active()
    """
    # GIVEN: A LibreOfficeServer instance and a bunch of mocks
    server = LibreOfficeServer()
    mocked_control = MagicMock()
    server._control = mocked_control
    mocked_control.isRunning.return_value = True

    # WHEN: is_active() is called with is_loaded() returns False
    with patch.object(server, 'is_loaded') as mocked_is_loaded:
        mocked_is_loaded.return_value = True
        result = server.is_active()

    # THEN: The result should be False
    assert result is True
    mocked_is_loaded.assert_called_once_with()
    mocked_control.isRunning.assert_called_once_with()