allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject git commit: [#6817] fix filename logic in import attachment handling
Date Fri, 01 Nov 2013 20:25:41 GMT
Updated Branches:
  refs/heads/db/6817 [created] da17816fc


[#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/da17816f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/da17816f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/da17816f

Branch: refs/heads/db/6817
Commit: da17816fc89b2f61d5b572e59108130cf45e9c73
Parents: 2ccaae5
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Fri Nov 1 20:25:23 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri Nov 1 20:25:30 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/da17816f/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/da17816f/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