In FileBase, self.extension is now always lowercase

pull/8/head
Dan Puttick 2016-12-22 10:12:13 -05:00
parent 43c01e0f05
commit d4bfe794be
2 changed files with 12 additions and 1 deletions

View File

@ -45,9 +45,13 @@ class FileBase(object):
self.dst_path = dst_path
self.log_details = {'filepath': self.src_path}
self.log_string = ''
_, self.extension = os.path.splitext(self.src_path)
self._determine_extension()
self._determine_mimetype()
def _determine_extension(self):
_, ext = os.path.splitext(self.src_path)
self.extension = ext.lower()
def _determine_mimetype(self):
if os.path.islink(self.src_path):
# magic will throw an IOError on a broken symlink

View File

@ -113,6 +113,13 @@ class TestFileBase:
# assert file.log_details == copied_log # this fails for now, we need to make log_details undeletable
# we should probably check for more extensions here
def test_extension_uppercase(self, tmpdir):
file_path = tmpdir.join('TEST.TXT')
file_path.write('testing')
file_path = file_path.strpath
file = FileBase(file_path, file_path)
assert file.extension == '.txt'
def test_mimetypes(self, generic_conf_file):
assert generic_conf_file.has_mimetype()
assert generic_conf_file.mimetype == 'text/plain'