-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cut down on actual usages of the Aquarius class by introducing a supe…
…rclass for certain unit test cases.
- Loading branch information
Showing
14 changed files
with
108 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import unittest | ||
from aquarius.Aquarius import Aquarius | ||
|
||
|
||
class ConsoleTestBase(unittest.TestCase): | ||
|
||
def initialise_app_mock(self): | ||
self.app = Aquarius(None, None, None, None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,34 @@ | ||
import unittest | ||
from unittest.mock import Mock | ||
|
||
from aquarius.Aquarius import Aquarius | ||
from aquarius.objects.Book import Book | ||
from aquarius.output.console.ConsoleStrings import ConsoleStrings | ||
from aquarius.output.console.SearchScreen import SearchScreen | ||
from tests.output.console.ConsoleTestBase import ConsoleTestBase | ||
|
||
|
||
class TestSearchScreen(unittest.TestCase): | ||
class TestSearchScreen(ConsoleTestBase): | ||
|
||
def setUp(self): | ||
self.__initialise_app() | ||
self.initialise_app_mock() | ||
self.__initialise_search_screen() | ||
self.__initialiseStringsMock() | ||
self.__initialise_strings_mock() | ||
self.__search_screen.SetStringsObject(self.__strings) | ||
|
||
def __initialiseStringsMock(self): | ||
def initialise_app_mock(self): | ||
ConsoleTestBase.initialise_app_mock(self) | ||
self.app.search_books = Mock(return_value=[Book()]) | ||
|
||
def __initialise_strings_mock(self): | ||
self.__strings = ConsoleStrings() | ||
self.__strings.get_search_result_title_string = Mock() | ||
self.__strings.get_search_result_footer_string = Mock() | ||
|
||
def __initialise_app(self): | ||
self.__app = Aquarius("hardcoded", None, None, None) | ||
self.__app.search_books = Mock(return_value=[Book()]) | ||
|
||
def __initialise_search_screen(self): | ||
self.__search_screen = SearchScreen(self.__app) | ||
self.__search_screen = SearchScreen(self.app) | ||
self.__search_screen.input = lambda: None | ||
|
||
def testMainDoesTheSearch(self): | ||
def test_main_does_search(self): | ||
self.__search_screen.main() | ||
self.assertTrue(self.__strings.get_search_result_title_string.called) | ||
self.assertTrue(self.__strings.get_search_result_footer_string.called) | ||
self.assertTrue(self.__app.search_books.called) | ||
self.assertTrue(self.app.search_books.called) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import unittest | ||
from aquarius.Aquarius import Aquarius | ||
|
||
|
||
class RequestHandlerTestBase(unittest.TestCase): | ||
|
||
def initialise_app_mock(self): | ||
self.app = Aquarius(None, None, None, None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 5 additions & 6 deletions
11
tests/output/web/requesthandlers/TestHtmlRequestHandlerBook.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 4 additions & 5 deletions
9
tests/output/web/requesthandlers/TestHtmlRequestHandlerDownload.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
import unittest | ||
|
||
from aquarius.Aquarius import Aquarius | ||
from aquarius.output.web.requesthandlers.HtmlRequestHandlerDownload import HtmlRequestHandlerDownload | ||
from tests.output.web.requesthandlers.TestHtmlRequestHandler import TestHtmlRequestHandler | ||
|
||
|
||
class TestHtmlRequestHandlerDownload(unittest.TestCase): | ||
class TestHtmlRequestHandlerDownload(TestHtmlRequestHandler): | ||
|
||
def test_can_initialise(self): | ||
HtmlRequestHandlerDownload(Aquarius(None, None, None, None)) | ||
self.initialise_app_mock() | ||
HtmlRequestHandlerDownload(self.app) |
17 changes: 8 additions & 9 deletions
17
tests/output/web/requesthandlers/TestHtmlRequestHandlerFirstLetter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 4 additions & 5 deletions
9
tests/output/web/requesthandlers/TestHtmlRequestHandlerIndex.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
import unittest | ||
|
||
from aquarius.Aquarius import Aquarius | ||
from aquarius.output.web.requesthandlers.HtmlRequestHandlerIndex import HtmlRequestHandlerIndex | ||
from tests.output.web.requesthandlers.RequestHandlerTestBase import RequestHandlerTestBase | ||
|
||
|
||
class TestHtmlRequestHandlerIndex(unittest.TestCase): | ||
class TestHtmlRequestHandlerIndex(RequestHandlerTestBase): | ||
|
||
def test_can_instantiate(self): | ||
HtmlRequestHandlerIndex(Aquarius(None, None, None, None)) | ||
RequestHandlerTestBase.initialise_app_mock(self) | ||
HtmlRequestHandlerIndex(self.app) |
16 changes: 8 additions & 8 deletions
16
tests/output/web/requesthandlers/TestHtmlRequestHandlerSearch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.