jeroanan / Aquarius

Aquarius -- EBook collection management and distribution done right.
GNU General Public License v3.0
0 stars 0 forks source link

Eliminate aquarius/persistence/sqlitepersistence/tests/Mocks #10

Open jeroanan opened 10 years ago

jeroanan commented 10 years ago

A lot, if not all, of the classes in this directory look something like this:

class AddBookSpy(AddBook):
    def __init__(self):
        self.add_book_calls = 0

    def add_book(self, book, connection):
        self.add_book_calls += 1

    def add_format(self, book, connection, f):
        pass

This basic sort of spy functionality could be done a lot more cleanly with unittest.Mock. We'd save on having a bunch of files lying around and on long lists of references in the unit test files. Once these classes are unused they can be deleted. Ultimately the whole folder can go.

jeroanan commented 10 years ago

I've got rid of the vast majority of these classes -- see commit 5937aecaf9b3343cf178388a335df37d2cd42637 -- ConnectionSpy and ParameterSanitiserSpy remain for now because of their large number of uses. In the case of ConnectionSpy in particular, I need to consider the implications on system design before removing. I think the way it's being used highlights some problems we have in the query objects in sqlite persistence with regards to the Single Responsibility Principle.