Test and PEP8 fixes

This commit is contained in:
Philip Ridout 2019-02-27 22:14:08 +00:00
parent 670c06db60
commit f3485513f1
2 changed files with 11 additions and 15 deletions

View File

@ -133,15 +133,11 @@ def test_get_thread_worker_mising(MockRegistry):
# GIVEN: A mocked thread worker
MockRegistry.return_value.get.return_value.worker_threads = {}
try:
# WHEN: get_thread_worker() is called
get_thread_worker('test_thread')
assert False, 'A KeyError should have been raised'
except KeyError:
# THEN: The mocked worker is returned
pass
except Exception:
assert False, 'A KeyError should have been raised'
# WHEN: get_thread_worker() is called
result = get_thread_worker('test_thread')
# THEN: None should have been returned
assert result is None
@patch('openlp.core.threading.Registry')

View File

@ -22,6 +22,7 @@
"""
This module contains tests for the OpenLP song importer.
"""
from pathlib import Path
from unittest import TestCase
from unittest.mock import MagicMock, patch
@ -66,10 +67,9 @@ class TestOpenLPImport(TestCase):
importer.stop_import_flag = True
# WHEN: Import source is not a list
for source in ['not a list', 0]:
importer.import_source = source
importer.import_source = Path()
# THEN: do_import should return none and the progress bar maximum should not be set.
assert importer.do_import() is None, 'do_import should return None when import_source is not a list'
assert mocked_import_wizard.progress_bar.setMaximum.called is False, \
'setMaximum on import_wizard.progress_bar should not have been called'
# THEN: do_import should return none and the progress bar maximum should not be set.
assert importer.do_import() is None, 'do_import should return None when import_source is not a list'
assert mocked_import_wizard.progress_bar.setMaximum.called is False, \
'setMaximum on import_wizard.progress_bar should not have been called'