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 2019/11/13 23:14:12 UTC
[allura] 03/05: [#8340] some wiki increased coverage,
fix bug by restoring some code erronously removed earlier
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch db/8340
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 1376d66420759e01609d392d2e1813c28e8510cc
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Wed Nov 13 11:33:02 2019 -0500
[#8340] some wiki increased coverage, fix bug by restoring some code erronously removed earlier
---
ForgeWiki/forgewiki/tests/functional/test_rest.py | 4 +++
ForgeWiki/forgewiki/tests/functional/test_root.py | 30 +++++++++++++++++++++++
ForgeWiki/forgewiki/tests/test_app.py | 10 ++++++--
ForgeWiki/forgewiki/wiki_main.py | 11 +++++++++
4 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/ForgeWiki/forgewiki/tests/functional/test_rest.py b/ForgeWiki/forgewiki/tests/functional/test_rest.py
index 09c9b16..b06aa3d 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_rest.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_rest.py
@@ -39,6 +39,10 @@ class TestWikiApi(TestRestApiBase):
def setup_with_tools(self):
h.set_context('test', 'wiki', neighborhood='Projects')
+ def test_get_root(self):
+ r = self.app.get('/rest/p/test/wiki/')
+ assert_equal(r.json, {'pages': ['Home']})
+
def test_get_page(self):
r = self.app.get('/p/test/wiki/Home/')
discussion_url = r.html.find('form', id='edit_post')['action'][:-4]
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py
index d79937a..29be374 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -258,6 +258,11 @@ class TestRootController(TestController):
assert not response.html.find('a', {'data-dialog-id': '1'})
assert not response.html.find('a', {'data-dialog-id': '2'})
+ # view an older version
+ response = self.app.get('/wiki/tést/?version=1')
+ response.mustcontain('text1')
+ response.mustcontain(no='text2')
+
def test_page_diff(self):
self.app.post(
'/wiki/tést/update',
@@ -652,6 +657,19 @@ class TestRootController(TestController):
wiki_page2 = self.app.get('/wiki/tést/')
assert not wiki_page2.html.find('div', {'class': 'editbox'})
+ def test_change_home_page(self):
+ self.app.post('/wiki/tést/update', params={
+ 'title': 'our_néw_home',
+ 'text': 'sometext',
+ 'labels': '',
+ })
+ homepage_admin = self.app.get('/admin/wiki/home', validate_chunk=True)
+ assert_equal(homepage_admin.form['new_home'].value, 'Home')
+ homepage_admin.form['new_home'].value = 'our_néw_home'
+ homepage_admin.form.submit()
+ root_path = self.app.get('/wiki/', status=302)
+ assert root_path.location.endswith('/wiki/our_néw_home/'), root_path.location
+
def test_edit_mount_label(self):
r = self.app.get('/admin/wiki/edit_label', validate_chunk=True)
assert r.form['mount_label'].value == 'Wiki'
@@ -773,6 +791,18 @@ class TestRootController(TestController):
n = M.Notification.query.get(subject="[test:wiki] test-admin removed page bbb")
assert '222' in n.text
+ # view deleted page
+ response = response.click('bbb')
+ assert '(deleted)' in response
+ deletedpath = response.request.path_info
+
+ # undelete it
+ undelete_url = deletedpath + 'undelete'
+ response = self.app.post(undelete_url)
+ assert_equal(response.json, {'location': './edit'})
+ response = self.app.get(deletedpath + 'edit')
+ assert 'Edit bbb' in response
+
def test_mailto_links(self):
self.app.get('/wiki/test_mailto/')
params = {
diff --git a/ForgeWiki/forgewiki/tests/test_app.py b/ForgeWiki/forgewiki/tests/test_app.py
index 7934540..5abf101 100644
--- a/ForgeWiki/forgewiki/tests/test_app.py
+++ b/ForgeWiki/forgewiki/tests/test_app.py
@@ -124,7 +124,7 @@ class TestBulkExport(object):
assert not os.path.exists(os.path.join(temp_dir, 'wiki', str(self.page._id), 'test_file'))
-class TestEmail(object):
+class TestApp(object):
def setUp(self):
setup_basic_test()
@@ -159,4 +159,10 @@ class TestEmail(object):
msg = dict(payload=message, message_id=message_id, headers={'Subject': 'test'})
self.wiki.handle_message('A_New_Hope', msg)
post = M.Post.query.get(_id=message_id)
- assert_equal(post["text"], message)
\ No newline at end of file
+ assert_equal(post["text"], message)
+
+ def test_uninstall(self):
+ assert WM.Page.query.get(title='A New Hope')
+ # c.app.uninstall(c.project) errors out, but works ok in test_uninstall for repo tools. So instead:
+ c.project.uninstall_app('wiki')
+ assert not WM.Page.query.get(title='A New Hope')
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 50c80e2..55704e4 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -150,6 +150,17 @@ class ForgeWikiApp(Application):
page_name = self.default_root_page_name
return page_name
+ @root_page_name.setter
+ def root_page_name(self, new_root_page_name):
+ globals = WM.Globals.query.get(app_config_id=self.config._id)
+ if globals is not None:
+ globals.root = new_root_page_name
+ elif new_root_page_name != self.default_root_page_name:
+ globals = WM.Globals(
+ app_config_id=self.config._id, root=new_root_page_name)
+ if globals is not None:
+ session(globals).flush(globals)
+
def default_root_page_text(self):
return """Welcome to your wiki!