Exemple #1
0
def test_is_loaded_no_objects():
    """
    Test the is_loaded() method when there's no document or presentation
    """
    # GIVEN: A LibreOfficeServer instance and a bunch of mocks
    server = LibreOfficeServer()

    # WHEN: The is_loaded() method is called
    result = server.is_loaded()

    # THEN: The result should be false
    assert result is False
Exemple #2
0
def test_is_loaded_exception():
    """
    Test the is_loaded() method when an exception is thrown
    """
    # GIVEN: A LibreOfficeServer instance and a bunch of mocks
    server = LibreOfficeServer()
    mocked_document = MagicMock()
    server._document = mocked_document
    server._presentation = MagicMock()
    mocked_document.getPresentation.side_effect = Exception()

    # WHEN: The is_loaded() method is called
    result = server.is_loaded()

    # THEN: The result should be false
    assert result is False
    mocked_document.getPresentation.assert_called_once_with()
Exemple #3
0
def test_is_loaded_no_presentation():
    """
    Test the is_loaded() method when there's no presentation
    """
    # GIVEN: A LibreOfficeServer instance and a bunch of mocks
    server = LibreOfficeServer()
    mocked_document = MagicMock()
    server._document = mocked_document
    server._presentation = MagicMock()
    mocked_document.getPresentation.return_value = None

    # WHEN: The is_loaded() method is called
    result = server.is_loaded()

    # THEN: The result should be false
    assert result is False
    mocked_document.getPresentation.assert_called_once_with()