Skip to content

Commit

Permalink
Interactors are now subclasses of Interactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroanan committed May 31, 2014
1 parent 0c49f13 commit bedbc3f
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 3 deletions.
4 changes: 4 additions & 0 deletions aquarius/Interactor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Interactor(object):

def execute(self, param):
pass
5 changes: 4 additions & 1 deletion aquarius/interactors/AddBookInteractor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
class AddBookInteractor(object):
from aquarius.Interactor import Interactor


class AddBookInteractor(Interactor):

def __init__(self, persistence):
self.__persistence = persistence
Expand Down
5 changes: 4 additions & 1 deletion aquarius/interactors/ListBooksByFirstLetterInteractor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
class ListBooksByFirstLetterInteractor(object):
from aquarius.Interactor import Interactor


class ListBooksByFirstLetterInteractor(Interactor):

def __init__(self, persistence):
self.__persistence = persistence
Expand Down
5 changes: 4 additions & 1 deletion aquarius/interactors/SearchBookInteractor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
class SearchBookInteractor(object):
from aquarius.Interactor import Interactor


class SearchBookInteractor(Interactor):
def __init__(self, persistence):
self.__persistence = persistence

Expand Down
10 changes: 10 additions & 0 deletions tests/TestInteractor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import unittest
from aquarius.Interactor import Interactor


class TestInteractor(unittest.TestCase):

def TestExecute(self):
i = Interactor()
i.execute("param")

5 changes: 5 additions & 0 deletions tests/interactors/TestAddBookInteractor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest
from unittest.mock import Mock
from aquarius.Interactor import Interactor
from aquarius.interactors.AddBookInteractor import AddBookInteractor
from aquarius.objects.Book import Book
from aquarius.objects.BookFormat import BookFormat
Expand All @@ -8,6 +9,10 @@

class TestAddBookInteractor(unittest.TestCase):

def test_is_instance_of_interactor(self):
target = AddBookInteractor(None)
self.assertIsInstance(target, Interactor)

def test_execute_gets_book_from_persistence(self):
persistence = Mock(SqlitePersistence)
persistence.get_book_by_title_and_author = Mock(return_value=(self.__get_book()))
Expand Down
5 changes: 5 additions & 0 deletions tests/interactors/TestListBooksByFirstLetterInteractor.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import unittest
from unittest.mock import Mock
from aquarius.Interactor import Interactor
from aquarius.interactors.ListBooksByFirstLetterInteractor import ListBooksByFirstLetterInteractor
from aquarius.persistence.sqlitepersistence.SqlitePersistence import SqlitePersistence


class TestListBooksByFirstLetterInteractor(unittest.TestCase):

def test_is_instance_of_interactor(self):
i = ListBooksByFirstLetterInteractor(None)
self.assertIsInstance(i, Interactor)

def test_execute_calls_persistence(self):
persistence = Mock(SqlitePersistence)
i = ListBooksByFirstLetterInteractor(persistence)
Expand Down
5 changes: 5 additions & 0 deletions tests/interactors/TestSearchBookInteractor.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import unittest
from unittest.mock import Mock
from aquarius.Interactor import Interactor
from aquarius.interactors.SearchBookInteractor import SearchBookInteractor
from aquarius.persistence.sqlitepersistence.SqlitePersistence import SqlitePersistence


class TestSearchBookInteractor(unittest.TestCase):

def test_is_instance_of_interactor(self):
i = SearchBookInteractor(None)
self.assertIsInstance(i, Interactor)

def test_execute(self):
persistence = Mock(SqlitePersistence)
i = SearchBookInteractor(persistence)
Expand Down

0 comments on commit bedbc3f

Please sign in to comment.