tests and bug fixes

This commit is contained in:
evilchili
2022-12-07 23:41:49 -08:00
parent af33e91232
commit 228d44ce98
7 changed files with 48 additions and 23 deletions
+4 -4
View File
@@ -44,7 +44,7 @@ def static_root():
dirname = os.environ.get('STATIC_PATH', 'static')
path = root() / Path(dirname)
if not path.exists() or not path.is_dir():
raise ConfigurationError(
raise ConfigurationError( # pragma: no cover
f"The static assets directory {dirname} (STATIC_PATH) "
f"doesn't exist, or isn't a directory.\n\n{_reinstall_hint}"
)
@@ -56,7 +56,7 @@ def static(relpath, theme=None):
if theme:
root = theme.path / Path('static')
if not root.is_dir():
raise ThemeConfigurationError(
raise ThemeConfigurationError( # pragma: no cover
f"The themes directory {relpath} (THEMES_PATH) "
f"doesn't contain a 'static' directory."
)
@@ -73,7 +73,7 @@ def themes_root():
dirname = os.environ.get('THEMES_PATH', 'themes')
path = root() / Path(dirname)
if not path.exists() or not path.is_dir():
raise ConfigurationError(
raise ConfigurationError( # pragma: no cover
f"The themes directory {dirname} (THEMES_PATH) "
f"doesn't exist, or isn't a directory.\n\n{_reinstall_hint}"
)
@@ -84,7 +84,7 @@ def themes_root():
def theme(name):
path = themes_root() / Path(name)
if not path.exists() or not path.is_dir():
available = ','.join(available_themes)
available = ','.join(available_themes())
raise ThemeMissingException(
f"A theme directory named {name} does not exist or isn't a directory. "
"Perhaps there is a typo in the name?\n"
+1 -1
View File
@@ -7,7 +7,7 @@ class BasePrompt(Completer):
def __init__(self, manager=None, parent=None):
super(BasePrompt, self).__init__()
if (not manager and not parent):
if (not manager and not parent): # pragma: no cover
raise RuntimeError("Must define either a database manager or a parent object.")
self._prompt = ''
+11 -13
View File
@@ -33,7 +33,7 @@ class CommandPrompt(BasePrompt):
def values(self):
return [k for k in self.commands.keys() if not k.startswith('_')]
def default_completer(self, document, complete_event):
def default_completer(self, document, complete_event): # pragma: no cover
def _formatter(row):
self._playlist = Playlist.from_row(row, self.manager.session)
return self.playlist.record.name
@@ -47,19 +47,17 @@ class CommandPrompt(BasePrompt):
name = cmd + ' ' + ' '.join(parts)
if cmd in self.commands:
self.commands[cmd].start(name)
else:
self._playlist = Playlist(
slug=slugify(name),
name=name,
session=self.manager.session,
create_ok=True
)
res = self.commands['_playlist'].start()
if res is False:
return res
return True
return True
self._playlist = Playlist(
slug=slugify(name),
name=name,
session=self.manager.session,
create_ok=True
)
res = self.commands['_playlist'].start()
return True and res
def start():
def start(): # pragma: no cover
with database_manager() as manager:
CommandPrompt(manager).start()