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/05/30 18:41:47 UTC
[02/24] git commit: [#6267] ticket:360 Test for wiki api post
[#6267] ticket:360 Test for wiki api post
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/1af5b404
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/1af5b404
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/1af5b404
Branch: refs/heads/cj/6218
Commit: 1af5b404be848880c79864a601e57c700029398c
Parents: 82f675f
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri May 24 12:54:39 2013 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Mon May 27 09:02:18 2013 +0000
----------------------------------------------------------------------
ForgeWiki/forgewiki/tests/functional/test_rest.py | 44 ++++++++++++++++
ForgeWiki/forgewiki/tests/functional/test_root.py | 15 -----
2 files changed, 44 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1af5b404/ForgeWiki/forgewiki/tests/functional/test_rest.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_rest.py b/ForgeWiki/forgewiki/tests/functional/test_rest.py
new file mode 100644
index 0000000..af1080a
--- /dev/null
+++ b/ForgeWiki/forgewiki/tests/functional/test_rest.py
@@ -0,0 +1,44 @@
+import json
+
+from nose.tools import assert_equal
+
+from allura.lib import helpers as h
+from allura.tests import decorators as td
+from alluratest.controller import TestRestApiBase
+
+
+class TestWikiApi(TestRestApiBase):
+
+ def setUp(self):
+ super(TestWikiApi, self).setUp()
+ self.setup_with_tools()
+
+ @td.with_wiki
+ def setup_with_tools(self):
+ h.set_context('test', 'wiki', neighborhood='Projects')
+
+ def test_get_page(self):
+ r = self.app.get('/p/test/wiki/Home/')
+ discussion_url = r.html.findAll('form')[2]['action'][:-4]
+ content = file(__file__).read()
+ self.app.post('/wiki/Home/attach', upload_files=[('file_info', 'test_root.py', content)])
+ r = self.app.get('/rest/p/test/wiki/Home/')
+ r = json.loads(r.body)
+ assert_equal(r['attachments'][0]['url'], 'http://localhost:80/p/test/wiki/Home/attachment/test_root.py')
+ assert_equal(r['discussion_thread_url'], 'http://localhost:80/rest%s' % discussion_url)
+ assert_equal(r['discussion_thread']['_id'], discussion_url.split('/')[-2])
+ self.app.post('/wiki/Home/attach', upload_files=[('file_info', '__init__.py', content),])
+ r = self.app.get('/rest/p/test/wiki/Home/')
+ r = json.loads(r.body)
+ assert_equal(len(r['attachments']), 2)
+
+ def test_post_page(self):
+ data = {
+ 'text': 'Embrace the Dark Side',
+ 'labels': 'head hunting,dark side'
+ }
+ r = self.api_post('/rest/p/test/wiki/Home/', **data)
+ assert_equal(r.status_int, 200)
+ r = self.api_get('/rest/p/test/wiki/Home/')
+ assert_equal(r.json['text'], data['text'])
+ assert_equal(r.json['labels'], data['labels'].split(','))
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1af5b404/ForgeWiki/forgewiki/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py
index 1baa28b..362d8bd 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -621,18 +621,3 @@ class TestRootController(TestController):
def test_user_browse_page(self):
r = self.app.get('/wiki/browse_pages/')
assert '<td>Test Admin (test-admin)</td>' in r
-
- def test_rest_wiki(self):
- r = self.app.get('/p/test/wiki/Home/')
- discussion_url = r.html.findAll('form')[2]['action'][:-4]
- content = file(__file__).read()
- self.app.post('/wiki/Home/attach', upload_files=[('file_info', 'test_root.py', content)])
- r = self.app.get('/rest/p/test/wiki/Home/')
- r = json.loads(r.body)
- assert_equal(r['attachments'][0]['url'], 'http://localhost:80/p/test/wiki/Home/attachment/test_root.py')
- assert_equal(r['discussion_thread_url'], 'http://localhost:80/rest%s' % discussion_url)
- assert_equal(r['discussion_thread']['_id'], discussion_url.split('/')[-2])
- self.app.post('/wiki/Home/attach', upload_files=[('file_info', '__init__.py', content),])
- r = self.app.get('/rest/p/test/wiki/Home/')
- r = json.loads(r.body)
- assert_equal(len(r['attachments']), 2)