|
a/ForgeBlog/forgeblog/tests/test_app.py |
|
b/ForgeBlog/forgeblog/tests/test_app.py |
|
... |
|
... |
17 |
|
17 |
|
18 |
#-*- python -*-
|
18 |
#-*- python -*-
|
19 |
|
19 |
|
20 |
import tempfile
|
20 |
import tempfile
|
21 |
import json
|
21 |
import json
|
|
|
22 |
|
22 |
from nose.tools import assert_equal
|
23 |
from nose.tools import assert_equal
|
|
|
24 |
from pylons import tmpl_context as c
|
23 |
|
25 |
|
24 |
from allura import model as M
|
26 |
from allura import model as M
|
25 |
from allura.lib import helpers as h
|
27 |
from allura.lib import helpers as h
|
26 |
from alluratest.controller import setup_basic_test, setup_global_objects
|
28 |
from alluratest.controller import setup_basic_test, setup_global_objects
|
27 |
from allura.tests import decorators as td
|
29 |
from allura.tests import decorators as td
|
|
... |
|
... |
34 |
setup_basic_test()
|
36 |
setup_basic_test()
|
35 |
setup_global_objects()
|
37 |
setup_global_objects()
|
36 |
|
38 |
|
37 |
@td.with_tool('test', 'Blog', 'blog')
|
39 |
@td.with_tool('test', 'Blog', 'blog')
|
38 |
def test_bulk_export(self):
|
40 |
def test_bulk_export(self):
|
|
|
41 |
# Clear out some context vars, to properly simulate how this is run from the export task
|
|
|
42 |
# Besides, it's better not to need c context vars
|
|
|
43 |
c.app = c.project = None
|
|
|
44 |
|
39 |
project = M.Project.query.get(shortname='test')
|
45 |
project = M.Project.query.get(shortname='test')
|
40 |
blog = project.app_instance('blog')
|
46 |
blog = project.app_instance('blog')
|
41 |
h.set_context('test', 'blog', neighborhood='Projects')
|
47 |
with h.push_context('test', 'blog', neighborhood='Projects'):
|
42 |
post = BM.BlogPost()
|
48 |
post = BM.BlogPost()
|
43 |
post.title = 'Test title'
|
49 |
post.title = 'Test title'
|
44 |
post.text = 'test post'
|
50 |
post.text = 'test post'
|
45 |
post.labels = ['the firstlabel', 'the second label']
|
51 |
post.labels = ['the firstlabel', 'the second label']
|
46 |
post.make_slug()
|
52 |
post.make_slug()
|
47 |
post.commit()
|
53 |
post.commit()
|
48 |
post.discussion_thread.add_post(text='test comment')
|
54 |
post.discussion_thread.add_post(text='test comment')
|
49 |
post2 = BM.BlogPost()
|
55 |
post2 = BM.BlogPost()
|
50 |
post2.title = 'Test2 title'
|
56 |
post2.title = 'Test2 title'
|
51 |
post2.text = 'test2 post'
|
57 |
post2.text = 'test2 post'
|
52 |
post2.make_slug()
|
58 |
post2.make_slug()
|
53 |
post2.commit()
|
59 |
post2.commit()
|
54 |
|
60 |
|
55 |
f = tempfile.TemporaryFile()
|
61 |
f = tempfile.TemporaryFile()
|
56 |
blog.bulk_export(f)
|
62 |
blog.bulk_export(f)
|
57 |
f.seek(0)
|
63 |
f.seek(0)
|
58 |
blog = json.loads(f.read())
|
64 |
blog = json.loads(f.read())
|