Parent: [3f60d2] (diff)

Child: [3b2afc] (diff)

Download this file

test_commands.py    53 lines (40 with data), 1.7 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
import mock
from nose.tools import assert_raises
from datadiff.tools import assert_equal
import pylons
from alluratest.controller import setup_basic_test, setup_global_objects
from allura.command import script, set_neighborhood_level, set_neighborhood_private
from allura import model as M
test_config = 'test.ini#main'
class EmptyClass(object): pass
def setUp(self):
"""Method called by nose before running each test"""
#setup_basic_test(app_name='main_with_amqp')
setup_basic_test()
setup_global_objects()
def test_script():
cmd = script.ScriptCommand('script')
cmd.run([test_config, 'allura/tests/tscript.py' ])
cmd.command()
assert_raises(ValueError, cmd.run, [test_config, 'allura/tests/tscript_error.py' ])
def test_set_neighborhood_level():
neighborhood = M.Neighborhood.query.find().first()
n_id = neighborhood._id
cmd = set_neighborhood_level.SetNeighborhoodLevelCommand('setnblevel')
cmd.run([test_config, str(n_id), 'gold'])
cmd.command()
neighborhood = M.Neighborhood.query.get(_id=n_id)
assert neighborhood.level == 'gold'
def test_set_neighborhood_private():
neighborhood = M.Neighborhood.query.find().first()
n_id = neighborhood._id
cmd = set_neighborhood_private.SetNeighborhoodPrivateCommand('setnbprivate')
cmd.run([test_config, str(n_id), '1'])
cmd.command()
neighborhood = M.Neighborhood.query.get(_id=n_id)
assert neighborhood.allow_private
cmd = set_neighborhood_private.SetNeighborhoodPrivateCommand('setnbprivate')
cmd.run([test_config, str(n_id), '0'])
cmd.command()
neighborhood = M.Neighborhood.query.get(_id=n_id)
assert not neighborhood.allow_private