def test_spaced_title(self): self.post('save_page', data=dict(title='hello world', old_title='hello world', content='blah')) assert not Page.load('hello world') assert Page.load('hello_world') res = self.get('view_page', title='hello world') self.redirect(res, 'view_page', title='hello_world')
def test_rename_page(self): assert not Page.load('renamed') referer = url_for('view_page', title='to rename') res = self.post('save_page', data=dict(title='renamed', old_title='to rename', content='blah'), headers={'referer': referer}) assert res.status_code == HTTP_OK assert not Page.load('to rename') assert Page.load('renamed')
def test_delete_page(self): res = self.get('delete_page', title='to delete') assert res.status_code == HTTP_OK session = Session() before = session.query(Page).count() res = self.post('delete_page', title='to delete') self.redirect(res, 'home') after = session.query(Page).count() assert not Page.load('to delete') assert before-1 == after
def test_edit_page(self): res = self.get('edit_page', title='test') assert res.status_code == HTTP_OK referer = url_for('view_page', title='test') res = self.post('save_page', data=dict(title='test', old_title='test', content='xxx'), headers={'referer': referer}) assert res.status_code == HTTP_OK page = Page.load('test') assert page.content == 'xxx'
def test_create_page(self): res = self.get('create_page', title='test') self.redirect(res, 'view_page', title='test') res = self.get('create_page', title='new_page') assert res.status_code == HTTP_OK res = self.post('save_page', data=dict(title='new_page', old_title='new_page', content='blah')) page = Page.load('new_page') assert page assert page.title == 'new_page' assert page.content == 'blah'