allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject git commit: [#6817] fix filename logic in import attachment handling
Date Mon, 04 Nov 2013 21:21:56 GMT
Updated Branches:
  refs/heads/master 6e780416c -> 619e09e50


[#6817] fix filename logic in import attachment handling


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/619e09e5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/619e09e5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/619e09e5

Branch: refs/heads/master
Commit: 619e09e509ae0732121e4af8cb88886b97918b09
Parents: 6e78041
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Fri Nov 1 20:25:23 2013 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Mon Nov 4 21:21:22 2013 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/base.py            |  2 +-
 ForgeImporters/forgeimporters/tests/test_base.py | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/619e09e5/ForgeImporters/forgeimporters/base.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/base.py b/ForgeImporters/forgeimporters/base.py
index 68282ad..49d49a1 100644
--- a/ForgeImporters/forgeimporters/base.py
+++ b/ForgeImporters/forgeimporters/base.py
@@ -519,7 +519,7 @@ class File(object):
         extractor = ProjectExtractor(None, url, parser=stringio_parser)
         self.url = url
         self.filename = filename or os.path.basename(urlparse(url).path)
-        self.type = guess_mime_type(filename)
+        self.type = guess_mime_type(self.filename)
         self.file = extractor.page['data']
 
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/619e09e5/ForgeImporters/forgeimporters/tests/test_base.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/test_base.py b/ForgeImporters/forgeimporters/tests/test_base.py
index 5b4f138..b1b2e63 100644
--- a/ForgeImporters/forgeimporters/tests/test_base.py
+++ b/ForgeImporters/forgeimporters/tests/test_base.py
@@ -343,3 +343,14 @@ def test_save_importer_upload(giup, os):
 
     os.makedirs.side_effect = OSError(errno.EACCES, 'foo')
     assert_raises(OSError, base.save_importer_upload, 'project', 'file', 'data')
+
+
+class TestFile(object):
+
+    @mock.patch.object(base, 'ProjectExtractor', mock.MagicMock)
+    def test_type(self):
+        f = base.File('http://example.com/barbaz.jpg')
+        assert_equal(f.type, 'image/jpeg')
+
+        f = base.File('http://example.com/barbaz')
+        assert_equal(f.type, 'application/octet-stream')


Mime
View raw message