From d4bfe794be9fbf4a62acf407b9822d8c864abe52 Mon Sep 17 00:00:00 2001 From: Dan Puttick Date: Thu, 22 Dec 2016 10:12:13 -0500 Subject: [PATCH] In FileBase, self.extension is now always lowercase --- kittengroomer/helpers.py | 6 +++++- tests/test_helpers.py | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/kittengroomer/helpers.py b/kittengroomer/helpers.py index 9604c49..10dd6a9 100644 --- a/kittengroomer/helpers.py +++ b/kittengroomer/helpers.py @@ -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 diff --git a/tests/test_helpers.py b/tests/test_helpers.py index f59c862..0d0c338 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -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'