Child: [f48b10] (diff)

Download this file

test_root.py    80 lines (66 with data), 2.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import os
import Image, StringIO
import allura
from nose.tools import assert_true
from forgeblog.tests import TestController
from forgeblog import model
# These are needed for faking reactor actions
import mock
from allura.lib import helpers as h
from allura.command import reactor
from allura.ext.search import search_main
from ming.orm.ormsession import ThreadLocalORMSession
#---------x---------x---------x---------x---------x---------x---------x
# RootController methods exposed:
# index, new_page, search
# PageController methods exposed:
# index, edit, history, diff, raw, revert, update
# CommentController methods exposed:
# reply, delete
class TestRootController(TestController):
def test_root_index(self):
response = self.app.get('/blog/')
assert 'Recent posts' in response
def test_root_new_post(self):
response = self.app.get('/blog/new')
assert 'Please enter a title' in response
def _post(self, slug='', **kw):
d = {
'title':'My Post',
'text':'Nothing to see here',
'date':'2010/08/23',
'time':'00:00',
'labels':'',
'state':'published'}
d.update(kw)
r = self.app.post('/blog%s/save' % slug, params=d)
return r
def test_root_new_search(self):
self._post()
response = self.app.get('/blog/search?q=see')
assert 'Search' in response
def test_post_index(self):
self._post()
response = self.app.get('/blog/2010/08/my-post/')
assert 'Nothing' in response
def test_post_edit(self):
self._post()
response = self.app.get('/blog/2010/08/my-post/edit')
assert 'Nothing' in response
def test_post_history(self):
self._post()
self._post('/2010/08/my-post')
self._post('/2010/08/my-post')
response = self.app.get('/blog/2010/08/my-post/history')
assert 'My Post' in response
# two revisions are shown
assert '2 by Test Admin' in response
assert '1 by Test Admin' in response
def test_post_diff(self):
self._post()
self._post('/2010/08/my-post', text='sometext')
self.app.get('/blog/2010/08/my-post/revert?version=1')
response = self.app.get('/blog/2010/08/my-post/')
assert 'Unsubscribe' in response
response = self.app.get('/blog/2010/08/my-post/diff?v1=0&v2=0')
assert 'My Post' in response