Merge pull request #114 from jmathai/files-without-extension-gh-113
gh-113 Check for a file extension before doing a string in tuple cond…
This commit is contained in:
commit
4097889e04
|
@ -187,6 +187,7 @@ class Base(object):
|
|||
|
||||
extension = os.path.splitext(_file)[1][1:].lower()
|
||||
|
||||
if len(extension) > 0:
|
||||
for i in classes:
|
||||
if(extension in i.extensions):
|
||||
return i(_file)
|
||||
|
|
|
@ -15,6 +15,11 @@ sys.path.insert(0, os.path.abspath(os.path.dirname(os.path.dirname(os.path.realp
|
|||
|
||||
import helper
|
||||
from elodie.media.base import Base
|
||||
from elodie.media.media import Media
|
||||
from elodie.media.audio import Audio
|
||||
from elodie.media.text import Text
|
||||
from elodie.media.photo import Photo
|
||||
from elodie.media.video import Video
|
||||
|
||||
os.environ['TZ'] = 'GMT'
|
||||
|
||||
|
@ -33,3 +38,9 @@ def test_set_album_from_folder_invalid_file():
|
|||
|
||||
assert status == False, status
|
||||
|
||||
def test_get_class_by_file_without_extension():
|
||||
base_file = helper.get_file('withoutextension')
|
||||
|
||||
cls = Base.get_class_by_file(base_file, [Audio, Text, Photo, Video])
|
||||
|
||||
assert cls is None, cls
|
||||
|
|
Loading…
Reference in New Issue