Massive code refactoring, and some test rewrites.

This commit is contained in:
Mike Young
2019-11-15 14:45:42 -05:00
parent e012436011
commit d7279a73a7
127 changed files with 3960 additions and 345 deletions

0
app/tests/__init__.py Executable file
View File

16
app/tests/config_test.py Executable file
View File

@@ -0,0 +1,16 @@
import os
from ..lib.config import Config
class TestConfig:
config = Config(os.path.abspath(os.path.curdir))
def test_book_dir(self):
assert os.path.isdir(self.config.book_path)
def test_title(self):
assert 'pyShelf' in self.config.TITLE
def test_version(self):
assert self.config.VERSION is not None

35
app/tests/library_test.py Executable file
View File

@@ -0,0 +1,35 @@
import json
import os
from ..lib.config import Config
from ..lib.library import Catalogue
class Test_Config(Config):
def __init__(self):
Config.__init__(self, 'config.json')
_data = self.open_file()
def open_file(self, root='config.json'):
with open('config.json') as read_file:
data = json.load(read_file)
return data
class Test_Catalogue(Catalogue):
def __init__(self):
Catalogue.__init__(self, root=os.path.abspath('.'))
def filter_books(self):
self.book_shelf = 'app/'+self.book_shelf
return super().filter_books()
class TestCatalogue:
root = os.path.abspath(os.path.curdir)
config = Test_Config()
def test_filter_books(self):
book_list = Test_Catalogue().filter_books()
assert len(book_list) > 0