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 # GIVEN: A mocked thread worker
MockRegistry.return_value.get.return_value.worker_threads = {} MockRegistry.return_value.get.return_value.worker_threads = {}
try: # WHEN: get_thread_worker() is called
# WHEN: get_thread_worker() is called result = get_thread_worker('test_thread')
get_thread_worker('test_thread')
assert False, 'A KeyError should have been raised' # THEN: None should have been returned
except KeyError: assert result is None
# THEN: The mocked worker is returned
pass
except Exception:
assert False, 'A KeyError should have been raised'
@patch('openlp.core.threading.Registry') @patch('openlp.core.threading.Registry')

View File

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