Merge pull request #95 from StruckCroissant/master

Stripping channel whitesapce

Signed-off-by: Roland <roland@learningselfreliance.com>
This commit is contained in:
lrnselfreliance 2022-02-13 08:14:37 -07:00 • committed by Roland
commit 5425142adb
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
2 changed files with 7 additions and 2 deletions

View file

@ -49,7 +49,9 @@ def channel_post(_: Request, body: schema.ChannelPostRequest):
if not body.directory.is_dir() and body.mkdir:
make_media_directory(body.directory)
channel = lib.create_channel(body.__dict__) # TODO don't use the dataclass as a dict.
bd_edit = body.__dict__
bd_edit['name'] = bd_edit['name'].strip()
channel = lib.create_channel(bd_edit) # TODO don't use the dataclass as a dict.
# Refresh the videos asynchronously
from ..api import refresh_videos

View file

@ -50,7 +50,7 @@ class TestVideoAPI(TestAPI):
new_channel = dict(
directory=channel_directory,
match_regex='asdf',
name='Example Channel 1',
name=' Example Channel 1 ',
url='https://example.com/channel1',
)
@ -67,6 +67,9 @@ class TestVideoAPI(TestAPI):
self.assertIsNotNone(created)
self.assertIsNotNone(created['id'])
# Channel name leading/trailing whitespace should be stripped
assert created['name'] == 'Example Channel 1'
# Channel directory should be relative to the media directory
assert not pathlib.Path(created['directory']).is_absolute(), \
f'Channel directory is absolute: {created["directory"]}'