bf3b3d3d74
include img in manifest disclaimer in root cli script add blinker to dev tools version file included in package cli bug fixes
73 lines
2.8 KiB
Python
73 lines
2.8 KiB
Python
import json
|
|
from nose.tools import *
|
|
from flask import url_for
|
|
from realms.modules.wiki.models import cname_to_filename, filename_to_cname
|
|
from realms.lib.test import BaseTest
|
|
|
|
|
|
class WikiBaseTest(BaseTest):
|
|
def write_page(self, name, message=None, content=None):
|
|
return self.client.post(url_for('wiki.page_write', name=name),
|
|
data=dict(message=message, content=content))
|
|
|
|
|
|
class UtilTest(WikiBaseTest):
|
|
def test_cname_to_filename(self):
|
|
eq_(cname_to_filename('test'), 'test.md')
|
|
|
|
def test_filename_to_cname(self):
|
|
eq_(filename_to_cname('test-1-2-3.md'), 'test-1-2-3')
|
|
|
|
|
|
class WikiTest(WikiBaseTest):
|
|
def test_routes(self):
|
|
self.assert_200(self.client.get(url_for("wiki.create")))
|
|
self.write_page('test', message='test message', content='testing')
|
|
|
|
for route in ['page', 'edit', 'history']:
|
|
rv = self.client.get(url_for("wiki.%s" % route, name='test'))
|
|
self.assert_200(rv, "wiki.%s: %s" % (route, rv.status_code))
|
|
|
|
self.assert_200(self.client.get(url_for('wiki.index')))
|
|
|
|
def test_write_page(self):
|
|
self.assert_200(self.write_page('test', message='test message', content='testing'))
|
|
|
|
rv = self.client.get(url_for('wiki.page', name='test'))
|
|
self.assert_200(rv)
|
|
|
|
self.assert_context('name', 'test')
|
|
eq_(self.get_context_variable('page')['info']['message'], 'test message')
|
|
eq_(self.get_context_variable('page')['data'], 'testing')
|
|
|
|
def test_history(self):
|
|
self.assert_200(self.client.get(url_for('wiki.history', name='test')))
|
|
|
|
def test_delete_page(self):
|
|
self.app.config['WIKI_LOCKED_PAGES'] = ['test']
|
|
self.assert_403(self.client.delete(url_for('wiki.page_write', name='test')))
|
|
self.app.config['WIKI_LOCKED_PAGES'] = []
|
|
|
|
self.assert_200(self.client.delete(url_for('wiki.page_write', name='test')))
|
|
|
|
rv = self.client.get(url_for('wiki.page', name='test'))
|
|
self.assert_status(rv, 302)
|
|
|
|
def test_revert(self):
|
|
rv1 = self.write_page('test', message='test message', content='testing_old')
|
|
self.write_page('test', message='test message', content='testing_new')
|
|
data = json.loads(rv1.data)
|
|
self.client.post(url_for('wiki.revert'), data=dict(name='test', commit=data['sha']))
|
|
self.client.get(url_for('wiki.page', name='test'))
|
|
eq_(self.get_context_variable('page')['data'], 'testing_old')
|
|
self.assert_404(self.client.post(url_for('wiki.revert'), data=dict(name='test', commit='does not exist')))
|
|
|
|
self.app.config['WIKI_LOCKED_PAGES'] = ['test']
|
|
self.assert_403(self.client.post(url_for('wiki.revert'), data=dict(name='test', commit=data['sha'])))
|
|
self.app.config['WIKI_LOCKED_PAGES'] = []
|
|
|
|
|
|
class RelativePathTest(WikiTest):
|
|
def configure(self):
|
|
return dict(RELATIVE_PATH='wiki')
|