You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2020/04/13 17:43:19 UTC
[allura] 27/50: [#7935] Added test for add_posts with attachments
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
commit f6d08ecd38c3c21548efb31d4870e0274cdf02db
Author: Fahri Korkmaz <f....@codesys.com>
AuthorDate: Wed Mar 4 18:42:22 2020 +0100
[#7935] Added test for add_posts with attachments
---
.../forgeimporters/tests/forge/test_discussion.py | 45 ++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/ForgeImporters/forgeimporters/tests/forge/test_discussion.py b/ForgeImporters/forgeimporters/tests/forge/test_discussion.py
index feb9dfc..5cea6ab 100644
--- a/ForgeImporters/forgeimporters/tests/forge/test_discussion.py
+++ b/ForgeImporters/forgeimporters/tests/forge/test_discussion.py
@@ -26,6 +26,7 @@ from ming.odm import ThreadLocalORMSession
from allura import model as M
from forgeimporters.forge import discussion
from forgediscussion import utils
+from forgeimporters.base import File
class TestDiscussionImporter(TestCase):
@@ -887,6 +888,50 @@ class TestDiscussionImporter(TestCase):
pass
+ @mock.patch.object(discussion, 'File')
+ @mock.patch.object(discussion, 'c')
+ @mock.patch.object(discussion, 'h')
+ def test_add_posts_with_attachments(self, h, c, File):
+ """ This method checks if add_posts supports posts with attachment """
+
+ importer, app, thread, user, post = self.__init_add_posts_tests()
+ File.side_effect = ['a1', 'a2', 'a3']
+
+ _json = [
+ {
+ "attachments": [
+ {
+ "url": "http://www.foo.com/attachment0",
+ "path": "path/to/attachment0",
+ "bytes": 145
+ },
+ {
+ "url": "http://www.foo.com/attachment1",
+ "path": "path/to/attachment1",
+ "bytes": 184
+ },
+ {
+ "url": "http://www.foo.com/attachment2",
+ "path": "path/to/attachment2",
+ "bytes": 145
+ },
+ ],
+ "author": "user02",
+ "timestamp": "2020-01-29 22:42:58.478000",
+ "text": "asdf as",
+ "subject": "topic with attachments"
+ }
+ ]
+
+ importer.add_posts(thread, _json, app)
+
+ post.add_multiple_attachments.assert_called_once()
+ self.assertEqual(File.call_args_list, [
+ mock.call('http://www.foo.com/attachment0'),
+ mock.call('http://www.foo.com/attachment1'),
+ mock.call('http://www.foo.com/attachment2')
+ ])
+
def __init_add_posts_tests(self):
importer = discussion.ForgeDiscussionImporter()