2 more done

This commit is contained in:
Tim Bentley 2017-12-17 14:12:27 +00:00
parent 30b0461227
commit fbaeca26f2
3 changed files with 16 additions and 16 deletions

View File

@ -113,7 +113,7 @@ class TestRenderer(TestCase):
result = get_start_tags(given_raw_text) result = get_start_tags(given_raw_text)
# THEN: Check if the correct tuple is returned. # THEN: Check if the correct tuple is returned.
self.assertEqual(result, expected_tuple), 'A tuple should be returned containing the text with correct ' \ assert result == expected_tuple, 'A tuple should be returned containing the text with correct ' \
'tags, the opening tags, and the opening html tags.' 'tags, the opening tags, and the opening html tags.'
def test_word_split(self): def test_word_split(self):
@ -128,7 +128,7 @@ class TestRenderer(TestCase):
result_words = words_split(given_line) result_words = words_split(given_line)
# THEN: The word lists should be the same. # THEN: The word lists should be the same.
self.assertListEqual(result_words, expected_words) assert result_words == expected_words
def test_format_slide_logical_split(self): def test_format_slide_logical_split(self):
""" """
@ -145,7 +145,7 @@ class TestRenderer(TestCase):
result_words = renderer.format_slide(given_line, service_item) result_words = renderer.format_slide(given_line, service_item)
# THEN: The word lists should be the same. # THEN: The word lists should be the same.
self.assertListEqual(result_words, expected_words) assert result_words == expected_words
def test_format_slide_blank_before_split(self): def test_format_slide_blank_before_split(self):
""" """
@ -162,7 +162,7 @@ class TestRenderer(TestCase):
result_words = renderer.format_slide(given_line, service_item) result_words = renderer.format_slide(given_line, service_item)
# THEN: The blanks have been removed. # THEN: The blanks have been removed.
self.assertListEqual(result_words, expected_words) assert result_words == expected_words
def test_format_slide_blank_after_split(self): def test_format_slide_blank_after_split(self):
""" """
@ -179,7 +179,7 @@ class TestRenderer(TestCase):
result_words = renderer.format_slide(given_line, service_item) result_words = renderer.format_slide(given_line, service_item)
# THEN: The blanks have been removed. # THEN: The blanks have been removed.
self.assertListEqual(result_words, expected_words) assert result_words == expected_words
@patch('openlp.core.display.renderer.QtWebKitWidgets.QWebView') @patch('openlp.core.display.renderer.QtWebKitWidgets.QWebView')
@patch('openlp.core.display.renderer.build_lyrics_format_css') @patch('openlp.core.display.renderer.build_lyrics_format_css')

View File

@ -75,6 +75,6 @@ class TestScreenList(TestCase):
# THEN: The screen should have been added and the screens should be identical # THEN: The screen should have been added and the screens should be identical
new_screen_count = len(self.screens.screen_list) new_screen_count = len(self.screens.screen_list)
self.assertEqual(old_screen_count + 1, new_screen_count, 'The new_screens list should be bigger') assert old_screen_count + 1 == new_screen_count, 'The new_screens list should be bigger'
self.assertEqual(SCREEN, self.screens.screen_list.pop(), assert SCREEN == self.screens.screen_list.pop(), \
'The 2nd screen should be identical to the first screen') 'The 2nd screen should be identical to the first screen'

View File

@ -80,8 +80,8 @@ class TestDB(TestCase):
MockedMetaData.assert_called_with(bind=mocked_engine) MockedMetaData.assert_called_with(bind=mocked_engine)
mocked_sessionmaker.assert_called_with(autoflush=True, autocommit=False, bind=mocked_engine) mocked_sessionmaker.assert_called_with(autoflush=True, autocommit=False, bind=mocked_engine)
mocked_scoped_session.assert_called_with(mocked_sessionmaker_object) mocked_scoped_session.assert_called_with(mocked_sessionmaker_object)
self.assertIs(session, mocked_scoped_session_object, 'The ``session`` object should be the mock') assert session is mocked_scoped_session_object, 'The ``session`` object should be the mock'
self.assertIs(metadata, mocked_metadata, 'The ``metadata`` object should be the mock') assert metadata is mocked_metadata, 'The ``metadata`` object should be the mock'
def test_init_db_defaults(self): def test_init_db_defaults(self):
""" """
@ -94,8 +94,8 @@ class TestDB(TestCase):
session, metadata = init_db(db_url) session, metadata = init_db(db_url)
# THEN: Valid session and metadata objects should be returned # THEN: Valid session and metadata objects should be returned
self.assertIsInstance(session, ScopedSession, 'The ``session`` object should be a ``ScopedSession`` instance') assert isinstance(session, ScopedSession), 'The ``session`` object should be a ``ScopedSession`` instance'
self.assertIsInstance(metadata, MetaData, 'The ``metadata`` object should be a ``MetaData`` instance') assert isinstance(metadata, MetaData), 'The ``metadata`` object should be a ``MetaData`` instance'
def test_get_upgrade_op(self): def test_get_upgrade_op(self):
""" """
@ -116,7 +116,7 @@ class TestDB(TestCase):
op = get_upgrade_op(mocked_session) op = get_upgrade_op(mocked_session)
# THEN: The op object should be mocked_op, and the correction function calls should have been made # THEN: The op object should be mocked_op, and the correction function calls should have been made
self.assertIs(op, mocked_op, 'The return value should be the mocked object') assert op is mocked_op, 'The return value should be the mocked object'
mocked_session.bind.connect.assert_called_with() mocked_session.bind.connect.assert_called_with()
MockedMigrationContext.configure.assert_called_with(mocked_connection) MockedMigrationContext.configure.assert_called_with(mocked_connection)
MockedOperations.assert_called_with(mocked_context) MockedOperations.assert_called_with(mocked_context)
@ -139,7 +139,7 @@ class TestDB(TestCase):
# THEN: The AppLocation.get_section_data_path and delete_file methods should have been called # THEN: The AppLocation.get_section_data_path and delete_file methods should have been called
MockedAppLocation.get_section_data_path.assert_called_with(test_plugin) MockedAppLocation.get_section_data_path.assert_called_with(test_plugin)
mocked_delete_file.assert_called_with(test_location) mocked_delete_file.assert_called_with(test_location)
self.assertTrue(result, 'The result of delete_file should be True (was rigged that way)') assert result is True, 'The result of delete_file should be True (was rigged that way)'
def test_delete_database_with_db_file_name(self): def test_delete_database_with_db_file_name(self):
""" """
@ -160,7 +160,7 @@ class TestDB(TestCase):
# THEN: The AppLocation.get_section_data_path and delete_file methods should have been called # THEN: The AppLocation.get_section_data_path and delete_file methods should have been called
MockedAppLocation.get_section_data_path.assert_called_with(test_plugin) MockedAppLocation.get_section_data_path.assert_called_with(test_plugin)
mocked_delete_file.assert_called_with(test_location) mocked_delete_file.assert_called_with(test_location)
self.assertFalse(result, 'The result of delete_file should be False (was rigged that way)') assert result is False, 'The result of delete_file should be False (was rigged that way)'
def test_skip_db_upgrade_with_no_database(self): def test_skip_db_upgrade_with_no_database(self):
""" """
@ -174,4 +174,4 @@ class TestDB(TestCase):
upgrade_db(url, mocked_upgrade) upgrade_db(url, mocked_upgrade)
# THEN: upgrade should NOT have been called # THEN: upgrade should NOT have been called
self.assertFalse(mocked_upgrade.called, 'Database upgrade function should NOT have been called') assert mocked_upgrade.called is False, 'Database upgrade function should NOT have been called'