mirror of https://github.com/CIRCL/PyCIRCLean
In FileBase, self.extension is now always lowercase
parent
43c01e0f05
commit
d4bfe794be
|
@ -45,9 +45,13 @@ class FileBase(object):
|
||||||
self.dst_path = dst_path
|
self.dst_path = dst_path
|
||||||
self.log_details = {'filepath': self.src_path}
|
self.log_details = {'filepath': self.src_path}
|
||||||
self.log_string = ''
|
self.log_string = ''
|
||||||
_, self.extension = os.path.splitext(self.src_path)
|
self._determine_extension()
|
||||||
self._determine_mimetype()
|
self._determine_mimetype()
|
||||||
|
|
||||||
|
def _determine_extension(self):
|
||||||
|
_, ext = os.path.splitext(self.src_path)
|
||||||
|
self.extension = ext.lower()
|
||||||
|
|
||||||
def _determine_mimetype(self):
|
def _determine_mimetype(self):
|
||||||
if os.path.islink(self.src_path):
|
if os.path.islink(self.src_path):
|
||||||
# magic will throw an IOError on a broken symlink
|
# magic will throw an IOError on a broken symlink
|
||||||
|
|
|
@ -113,6 +113,13 @@ class TestFileBase:
|
||||||
# assert file.log_details == copied_log # this fails for now, we need to make log_details undeletable
|
# 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
|
# 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):
|
def test_mimetypes(self, generic_conf_file):
|
||||||
assert generic_conf_file.has_mimetype()
|
assert generic_conf_file.has_mimetype()
|
||||||
assert generic_conf_file.mimetype == 'text/plain'
|
assert generic_conf_file.mimetype == 'text/plain'
|
||||||
|
|
Loading…
Reference in New Issue