You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/07/16 22:17:07 UTC

[06/27] git commit: [#4659] ticket:381 test for multiple attachments

[#4659]  ticket:381 test for multiple attachments


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

Branch: refs/heads/cj/4656
Commit: 94026f295048ff34325d51ea420ebdc5d71f567a
Parents: 870f5aa
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Mon Jul 8 08:47:11 2013 +0400
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Thu Jul 11 14:35:13 2013 +0000

----------------------------------------------------------------------
 Allura/allura/tests/model/test_discussion.py | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/94026f29/Allura/allura/tests/model/test_discussion.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_discussion.py b/Allura/allura/tests/model/test_discussion.py
index 72920e6..4ac1e37 100644
--- a/Allura/allura/tests/model/test_discussion.py
+++ b/Allura/allura/tests/model/test_discussion.py
@@ -206,6 +206,28 @@ def test_attachment_methods():
     n = M.Notification.query.get(subject=u'[test:wiki] Test comment notification')
     assert '\nAttachment: fake.txt (37 Bytes; text/plain)' in n.text
 
+@with_setup(setUp, tearDown())
+def test_multiple_attach():
+    test_file1 = FieldStorage()
+    test_file1.name = 'file_info'
+    test_file1.filename = 'test1.txt'
+    test_file1.type = 'text/plain'
+    test_file1.file=StringIO('test file1\n')
+    test_file2 = FieldStorage()
+    test_file2.name = 'file_info'
+    test_file2.filename = 'test2.txt'
+    test_file2.type = 'text/plain'
+    test_file2.file=StringIO('test file2\n')
+    d = M.Discussion(shortname='test', name='test')
+    t = M.Thread.new(discussion_id=d._id, subject='Test Thread')
+    test_post = t.post('test post')
+    test_post.add_multiple_attach([test_file1, test_file2])
+    ThreadLocalORMSession.flush_all()
+    assert test_post.attachments.count() == 2, test_post.attachments.count()
+    attaches = test_post.attachments.all()
+    assert 'test1.txt' in [attaches[0].filename, attaches[1].filename]
+    assert 'test2.txt' in [attaches[0].filename, attaches[1].filename]
+
 @with_setup(setUp, tearDown)
 def test_add_attachment():
     test_file = FieldStorage()