forked from openlp/openlp
core-ui-media-__init__: Create test and fix docstring error for format_milliseconds(...). Achieve 100% coverage for __init__.py module
This commit is contained in:
parent
ffd25be049
commit
5935bbe850
@ -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)
|
||||
|
@ -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"
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user