From 5935bbe85011dee9fa6399d38a277e97d70fe0b3 Mon Sep 17 00:00:00 2001 From: Ee Savior <2930438-eSavior@users.noreply.gitlab.com> Date: Mon, 2 Dec 2019 18:02:13 +0000 Subject: [PATCH] core-ui-media-__init__: Create test and fix docstring error for format_milliseconds(...). Achieve 100% coverage for __init__.py module --- openlp/core/ui/media/__init__.py | 2 +- .../openlp_core/ui/media/test_media.py | 16 ++++++++++++++++ .../songs/forms/test_songmaintenanceform.py | 1 - 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/media/__init__.py b/openlp/core/ui/media/__init__.py index 52662c7f6..1524b161a 100644 --- a/openlp/core/ui/media/__init__.py +++ b/openlp/core/ui/media/__init__.py @@ -108,7 +108,7 @@ def format_milliseconds(milliseconds): """ Format milliseconds into a human readable time string. :param milliseconds: Milliseconds to format - :return: Time string in format: hh.mm.ss,ttt + :return: Time string in format: hh:mm:ss,ttt """ milliseconds = int(milliseconds) seconds, millis = divmod(milliseconds, 1000) diff --git a/tests/functional/openlp_core/ui/media/test_media.py b/tests/functional/openlp_core/ui/media/test_media.py index 733969c28..1b70c3a29 100644 --- a/tests/functional/openlp_core/ui/media/test_media.py +++ b/tests/functional/openlp_core/ui/media/test_media.py @@ -22,6 +22,7 @@ Package to test the openlp.core.ui package. """ from openlp.core.ui.media import parse_optical_path +from openlp.core.ui.media import format_milliseconds def test_parse_optical_path_linux(): @@ -80,3 +81,18 @@ def test_parse_optical_path_win(): assert org_end == end, 'Returned end should match the original' assert org_name == name, 'Returned end should match the original' assert org_device_path == device_path, 'Returned device_path should match the original' + + +def test_format_milliseconds(): + """ + Test that format_milliseconds(...) makes an expected human readable time string + """ + + # GIVEN: 200 million milliseconds (Revelation 9:16) + num_soldiers_on_horses_as_milliseconds = 200 * 1000 * 1000 + + # WHEN: converting milliseconds to human readable string + num_soldiers_on_horses_as_formatted_time_string = format_milliseconds(num_soldiers_on_horses_as_milliseconds) + + # THEN: The formatted time string should be 55 hours, 33 minutes, 20 seconds, and 000 milliseconds + assert num_soldiers_on_horses_as_formatted_time_string == "55:33:20,000" diff --git a/tests/interfaces/openlp_plugins/songs/forms/test_songmaintenanceform.py b/tests/interfaces/openlp_plugins/songs/forms/test_songmaintenanceform.py index 4fb36618a..6647c07cb 100644 --- a/tests/interfaces/openlp_plugins/songs/forms/test_songmaintenanceform.py +++ b/tests/interfaces/openlp_plugins/songs/forms/test_songmaintenanceform.py @@ -232,7 +232,6 @@ class TestSongMaintenanceForm(TestCase, TestMixin): expected_widget_item_calls = [call('John Wesley'), call('John Newton')] mocked_authors_list_widget.clear.assert_called_once_with() self.mocked_manager.get_all_objects.assert_called_once_with(MockedAuthor) - # former third argument for below not needed anymore: MockedQListWidgetItem.call_args_list self.assertCountEqual(MockedQListWidgetItem.call_args_list, expected_widget_item_calls) mocked_author_item1.setData.assert_called_once_with(QtCore.Qt.UserRole, 2) mocked_author_item2.setData.assert_called_once_with(QtCore.Qt.UserRole, 1)