Fix up two tests

This commit is contained in:
Raoul Snyman 2017-03-10 15:48:59 -07:00
parent 324652c347
commit 4bae0fcd69
2 changed files with 5 additions and 2 deletions

View File

@ -24,7 +24,7 @@ import sys
from unittest import TestCase
from unittest.mock import MagicMock, patch
from openlp.core import parse_options
from openlp.core import OpenLP, parse_options
class TestInitFunctions(TestCase):

View File

@ -72,7 +72,9 @@ class TestSongSelectImport(TestCase, TestMixin):
mocked_build_opener.return_value = mocked_opener
mocked_login_page = MagicMock()
mocked_login_page.find.side_effect = [{'value': 'blah'}, None]
MockedBeautifulSoup.return_value = mocked_login_page
mocked_posted_page = MagicMock()
mocked_posted_page.find.return_value = None
MockedBeautifulSoup.side_effect = [mocked_login_page, mocked_posted_page]
mock_callback = MagicMock()
importer = SongSelectImport(None)
@ -82,6 +84,7 @@ class TestSongSelectImport(TestCase, TestMixin):
# THEN: callback was called 3 times, open was called twice, find was called twice, and False was returned
self.assertEqual(3, mock_callback.call_count, 'callback should have been called 3 times')
self.assertEqual(2, mocked_login_page.find.call_count, 'find should have been called twice')
self.assertEqual(1, mocked_posted_page.find.call_count, 'find should have been called once')
self.assertEqual(2, mocked_opener.open.call_count, 'opener should have been called twice')
self.assertFalse(result, 'The login method should have returned False')