annotate test/test_admin.py @ 7266:543b9d6d0e11

use latest 3-alpine at 18M rather than latest ubuntu based python image, dependabot seems to not properly track subypes
author John Rouillard <rouilj@ieee.org>
date Wed, 19 Apr 2023 22:30:00 -0400
parents af870e295b46
children bd6523c84a95
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5713
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
1 #
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
2 # Copyright (C) 2007 Stefan Seefeld
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
3 # All rights reserved.
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
4 # For license terms see the file COPYING.txt.
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
5 #
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
6
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
7 from __future__ import print_function
7204
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
8 import fileinput
5713
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
9 import unittest, os, shutil, errno, sys, difflib, cgi, re
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
10
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
11 from roundup.admin import AdminTool
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
12
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
13 from .test_mysql import skip_mysql
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
14 from .test_postgresql import skip_postgresql
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
15
6178
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
16 #from roundup import instance
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
17
6176
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
18 # https://stackoverflow.com/questions/4219717/how-to-assert-output-with-nosetest-unittest-in-python
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
19 # lightly modified
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
20 from contextlib import contextmanager
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
21 _py3 = sys.version_info[0] > 2
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
22 if _py3:
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
23 from io import StringIO # py3
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
24 else:
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
25 from StringIO import StringIO # py2
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
26
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
27 @contextmanager
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
28 def captured_output():
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
29 new_out, new_err = StringIO(), StringIO()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
30 old_out, old_err = sys.stdout, sys.stderr
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
31 try:
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
32 sys.stdout, sys.stderr = new_out, new_err
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
33 yield sys.stdout, sys.stderr
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
34 finally:
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
35 sys.stdout, sys.stderr = old_out, old_err
5713
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
36
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
37 def normalize_file(filename, skiplines = [ None ]):
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
38 # https://stackoverflow.com/questions/4710067/using-python-for-deleting-a-specific-line-in-a-file
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
39
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
40 with open(filename, "r+") as f:
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
41 d = f.readlines()
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
42 f.seek(0)
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
43 for i in d:
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
44 for skip in skiplines:
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
45 if skip not in i:
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
46 f.write(i)
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
47 f.truncate()
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
48
7204
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
49 def replace_in_file(filename, original, replacement):
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
50 """replace text in a file. All occurances of original
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
51 will be replaced by replacement"""
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
52
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
53 for line in fileinput.input(filename, inplace = 1):
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
54 print(line.replace(original, replacement))
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
55
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
56 fileinput.close()
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
57
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
58 def find_in_file(filename, regexp):
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
59 """search for regexp in file.
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
60 If not found return false. If found return match.
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
61 """
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
62 with open(filename) as f:
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
63 contents = f.read()
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
64
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
65 m = re.search(regexp, contents, re.MULTILINE)
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
66
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
67 if not m: return False
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
68
7205
1a3d4703c7d6 Fix for python2. m[0] -> m.group(0)
John Rouillard <rouilj@ieee.org>
parents: 7204
diff changeset
69 return m.group(0)
7204
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
70
5713
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
71 class AdminTest(object):
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
72
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
73 backend = None
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
74
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
75 def setUp(self):
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
76 self.dirname = '_test_admin'
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
77
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
78 def tearDown(self):
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
79 try:
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
80 shutil.rmtree(self.dirname)
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
81 except OSError as error:
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
82 if error.errno not in (errno.ENOENT, errno.ESRCH): raise
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
83
6176
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
84 def install_init(self, type="classic",
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
85 settings="mail_domain=example.com," +
6177
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
86 "mail_host=localhost," +
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
87 "tracker_web=http://test/," +
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
88 "rdbms_name=rounduptest," +
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
89 "rdbms_user=rounduptest," +
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
90 "rdbms_password=rounduptest," +
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
91 "rdbms_template=template0"
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
92 ):
6176
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
93 ''' install tracker with settings for required config.ini settings.
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
94 '''
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
95
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
96 admin=AdminTool()
6178
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
97 admin.force = True # force it to nuke existing tracker
6176
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
98
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
99 # Run under context manager to suppress output of help text.
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
100 with captured_output() as (out, err):
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
101 sys.argv=['main', '-i', self.dirname, 'install',
6176
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
102 type, self.backend, settings ]
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
103 ret = admin.main()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
104 self.assertEqual(ret, 0)
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
105
6178
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
106 # nuke any existing database (mysql/postgreql)
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
107 # possible method in case admin.force doesn't work
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
108 #tracker = instance.open(self.dirname)
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
109 #if tracker.exists():
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
110 # tracker.nuke()
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
111
6176
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
112 # initialize tracker with initial_data.py. Put password
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
113 # on cli so I don't have to respond to prompting.
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
114 sys.argv=['main', '-i', self.dirname, 'initialise', 'admin']
6178
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
115 admin.force = True # force it to nuke existing database
6176
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
116 ret = admin.main()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
117 self.assertEqual(ret, 0)
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
118
6178
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
119
7182
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
120 def testBasicInteractive(self):
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
121 # first command is an error that should be handled
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
122 inputs = iter(["'quit", "quit"])
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
123
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
124 orig_input = AdminTool.my_input
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
125
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
126 AdminTool.my_input = lambda _self, _prompt: next(inputs)
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
127
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
128 self.install_init()
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
129 self.admin=AdminTool()
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
130 sys.argv=['main', '-i', self.dirname]
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
131
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
132 with captured_output() as (out, err):
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
133 ret = self.admin.main()
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
134
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
135 out = out.getvalue().strip()
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
136
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
137 print(ret)
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
138 self.assertTrue(ret == 0)
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
139 expected = 'ready for input.\nType "help" for help.'
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
140 self.assertEqual(expected, out[-1*len(expected):])
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
141
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
142 inputs = iter(["list user", "quit"])
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
143
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
144 AdminTool.my_input = lambda _self, _prompt: next(inputs)
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
145
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
146 with captured_output() as (out, err):
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
147 ret = self.admin.main()
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
148
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
149 out = out.getvalue().strip()
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
150
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
151 print(ret)
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
152 self.assertTrue(ret == 0)
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
153 expected = 'help.\n 1: admin\n 2: anonymous'
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
154 self.assertEqual(expected, out[-1*len(expected):])
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
155
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
156
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
157 AdminTool.my_input = orig_input
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
158
6181
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
159 def testGet(self):
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
160 ''' Note the tests will fail if you run this under pdb.
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
161 the context managers capture the pdb prompts and this screws
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
162 up the stdout strings with (pdb) prefixed to the line.
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
163 '''
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
164 self.install_init()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
165 self.admin=AdminTool()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
166
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
167 with captured_output() as (out, err):
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
168 sys.argv=['main', '-i', self.dirname, 'create', 'issue',
6181
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
169 'title="foo bar"', 'assignedto=admin' ]
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
170 ret = self.admin.main()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
171
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
172 out = out.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
173 print(out)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
174 self.assertEqual(out, '1')
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
175
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
176 self.admin=AdminTool()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
177 with captured_output() as (out, err):
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
178 sys.argv=['main', '-i', self.dirname, 'create', 'issue',
6181
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
179 'title="bar foo bar"', 'assignedto=anonymous',
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
180 'superseder=1']
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
181 ret = self.admin.main()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
182
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
183 self.assertEqual(ret, 0)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
184 out = out.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
185 print(out)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
186 self.assertEqual(out, '2')
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
187
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
188 self.admin=AdminTool()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
189 with captured_output() as (out, err):
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
190 sys.argv=['main', '-i', self.dirname, 'get', 'assignedto',
6181
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
191 'issue2' ]
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
192 ret = self.admin.main()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
193
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
194 self.assertEqual(ret, 0)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
195 out = out.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
196 err = err.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
197 self.assertEqual(out, '2')
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
198 self.assertEqual(len(err), 0)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
199
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
200 self.admin=AdminTool()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
201 with captured_output() as (out, err):
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
202 sys.argv=['main', '-i', self.dirname, 'get', 'superseder',
6181
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
203 'issue2' ]
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
204 ret = self.admin.main()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
205
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
206 self.assertEqual(ret, 0)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
207 out = out.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
208 err = err.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
209 self.assertEqual(out, "['1']")
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
210 self.assertEqual(len(err), 0)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
211
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
212 self.admin=AdminTool()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
213 with captured_output() as (out, err):
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
214 sys.argv=['main', '-i', self.dirname, 'get', 'title', 'issue1']
6181
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
215 ret = self.admin.main()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
216
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
217 self.assertEqual(ret, 0)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
218 out = out.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
219 err = err.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
220 self.assertEqual(out, '"foo bar"') ## why is capture inserting "??
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
221 self.assertEqual(len(err), 0)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
222
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
223 self.admin=AdminTool()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
224 with captured_output() as (out, err):
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
225 sys.argv=['main', '-i', self.dirname, 'get', 'tile', 'issue1']
6181
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
226 ret = self.admin.main()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
227
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
228 expected_err = 'Error: no such issue property "tile"'
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
229
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
230 self.assertEqual(ret, 1)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
231 out = out.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
232 err = err.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
233 self.assertEqual(out.index(expected_err), 0)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
234 self.assertEqual(len(err), 0)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
235
6199
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
236 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
237 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
238 sys.argv=['main', '-i', self.dirname, 'get', 'title', 'issue']
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
239 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
240
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
241 expected_err = 'Error: "issue" not a node designator'
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
242
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
243 self.assertEqual(ret, 1)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
244 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
245 err = err.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
246 self.assertEqual(out.index(expected_err), 0)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
247 self.assertEqual(len(err), 0)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
248
5713
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
249 def testInit(self):
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
250 self.admin=AdminTool()
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
251 sys.argv=['main', '-i', self.dirname, 'install', 'classic', self.backend]
5713
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
252 ret = self.admin.main()
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
253 print(ret)
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
254 self.assertTrue(ret == 0)
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
255 self.assertTrue(os.path.isfile(self.dirname + "/config.ini"))
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
256 self.assertTrue(os.path.isfile(self.dirname + "/schema.py"))
5762
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
257
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
258 def testInitWithConfig_ini(self):
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
259 from roundup.configuration import CoreConfig
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
260 self.admin=AdminTool()
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
261 sys.argv=['main', '-i', self.dirname, 'install', 'classic', self.backend]
5762
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
262 # create a config_ini.ini file in classic template
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
263 templates=self.admin.listTemplates()
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
264 config_ini_content = "[mail]\n# comment\ndebug = SendMail.LOG\n"
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
265 config_ini_path = templates['classic']['path'] + '/config_ini.ini'
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
266 config_ini_file = open(config_ini_path, "w")
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
267 config_ini_file.write(config_ini_content)
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
268 config_ini_file.close()
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
269
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
270 try:
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
271 ret = self.admin.main()
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
272 finally:
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
273 try:
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
274 # ignore file not found
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
275 os.remove(config_ini_path)
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
276 except OSError as e: # FileNotFound exception under py3
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
277 if e.errno == 2:
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
278 pass
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
279 else:
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
280 raise
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
281
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
282 print(ret)
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
283 self.assertTrue(ret == 0)
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
284 self.assertTrue(os.path.isfile(self.dirname + "/config.ini"))
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
285 self.assertTrue(os.path.isfile(self.dirname + "/schema.py"))
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
286 config=CoreConfig(self.dirname)
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
287 self.assertEqual(config['MAIL_DEBUG'], self.dirname + "/SendMail.LOG")
6176
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
288
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
289 def testFind(self):
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
290 ''' Note the tests will fail if you run this under pdb.
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
291 the context managers capture the pdb prompts and this screws
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
292 up the stdout strings with (pdb) prefixed to the line.
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
293 '''
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
294 self.admin=AdminTool()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
295 self.install_init()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
296
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
297 with captured_output() as (out, err):
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
298 sys.argv=['main', '-i', self.dirname, 'create', 'issue',
6176
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
299 'title="foo bar"', 'assignedto=admin' ]
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
300 ret = self.admin.main()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
301
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
302 out = out.getvalue().strip()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
303 print(out)
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
304 self.assertEqual(out, '1')
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
305
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
306 self.admin=AdminTool()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
307 with captured_output() as (out, err):
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
308 sys.argv=['main', '-i', self.dirname, 'create', 'issue',
6176
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
309 'title="bar foo bar"', 'assignedto=anonymous' ]
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
310 ret = self.admin.main()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
311
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
312 out = out.getvalue().strip()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
313 print(out)
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
314 self.assertEqual(out, '2')
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
315
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
316 self.admin=AdminTool()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
317 with captured_output() as (out, err):
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
318 sys.argv=['main', '-i', self.dirname, 'find', 'issue',
6176
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
319 'assignedto=1']
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
320 ret = self.admin.main()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
321
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
322 out = out.getvalue().strip()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
323 print(out)
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
324 self.assertEqual(out, "['1']")
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
325
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
326 # Reopen the db closed by previous filter call
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
327 self.admin=AdminTool()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
328 with captured_output() as (out, err):
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
329 ''' 1,2 should return all entries that have assignedto
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
330 either admin or anonymous
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
331 '''
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
332 sys.argv=['main', '-i', self.dirname, 'find', 'issue',
6176
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
333 'assignedto=1,2']
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
334 ret = self.admin.main()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
335
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
336 out = out.getvalue().strip()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
337 print(out)
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
338 # out can be "['2', '1']" or "['1', '2']"
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
339 # so eval to real list so Equal can do a list compare
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
340 self.assertEqual(sorted(eval(out)), ['1', '2'])
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
341
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
342 # Reopen the db closed by previous filter call
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
343 self.admin=AdminTool()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
344 with captured_output() as (out, err):
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
345 ''' 1,2 should return all entries that have assignedto
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
346 either admin or anonymous
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
347 '''
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
348 sys.argv=['main', '-i', self.dirname, 'find', 'issue',
6176
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
349 'assignedto=admin,anonymous']
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
350 ret = self.admin.main()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
351
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
352 out = out.getvalue().strip()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
353 print(out)
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
354 # out can be "['2', '1']" or "['1', '2']"
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
355 # so eval to real list so Equal can do a list compare
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
356 self.assertEqual(sorted(eval(out)), ['1', '2'])
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
357
6188
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
358 def testGenconfigUpdate(self):
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
359 ''' Note the tests will fail if you run this under pdb.
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
360 the context managers capture the pdb prompts and this screws
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
361 up the stdout strings with (pdb) prefixed to the line.
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
362 '''
7182
0c6617db0b97 Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents: 7168
diff changeset
363 import filecmp
6188
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
364
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
365 self.admin=AdminTool()
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
366 self.install_init()
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
367
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
368 with captured_output() as (out, err):
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
369 sys.argv=['main', '-i', self.dirname, 'genconfig']
6188
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
370 ret = self.admin.main()
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
371
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
372 out = out.getvalue().strip()
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
373 print(out)
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
374 expected = "Not enough arguments supplied"
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
375 self.assertTrue(expected in out)
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
376
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
377 # Reopen the db closed by previous call
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
378 self.admin=AdminTool()
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
379
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
380 with captured_output() as (out, err):
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
381 sys.argv=['main', '-i', self.dirname, 'genconfig',
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
382 self.dirname + "/config2.ini"]
6188
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
383 ret = self.admin.main()
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
384
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
385 out = out.getvalue().strip()
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
386 print(out)
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
387 # FIXME get better successful test later.
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
388 expected = ""
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
389 self.assertTrue(expected in out)
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
390 self.assertTrue(os.path.isfile(self.dirname + "/config2.ini"))
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
391 # Files aren't the same. Lines need to be removed.
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
392 # like user, web, backend etc. Genconfig generates a file
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
393 # to be customized.
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
394 #self.assertTrue(filecmp.cmp(self.dirname + "/config2.ini",
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
395 # self.dirname + "/config.ini"))
6188
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
396
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
397 # Reopen the db closed by previous call
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
398 self.admin=AdminTool()
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
399
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
400 with captured_output() as (out, err):
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
401 sys.argv=['main', '-i', self.dirname, 'update',
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
402 self.dirname + "/foo2.ini"]
6188
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
403 ret = self.admin.main()
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
404
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
405 out = out.getvalue().strip()
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
406 print(out)
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
407 # FIXME get better successful test later.
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
408 expected = ""
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
409 self.assertTrue(expected in out)
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
410 self.assertTrue(os.path.isfile(self.dirname + "/foo2.ini"))
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
411
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
412 # Autogenerated date header is different. Remove it
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
413 # so filecmp passes.
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
414 normalize_file(self.dirname + "/foo2.ini",
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
415 [ '# Autogenerated at' ])
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
416 normalize_file(self.dirname + "/config.ini",
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
417 [ '# Autogenerated at' ])
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
418
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
419 self.assertTrue(filecmp.cmp(self.dirname + "/config.ini",
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
420 self.dirname + "/foo2.ini"))
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
421
7204
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
422 def testUpdateconfigPbkdf2(self):
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
423 ''' Note the tests will fail if you run this under pdb.
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
424 the context managers capture the pdb prompts and this screws
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
425 up the stdout strings with (pdb) prefixed to the line.
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
426 '''
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
427 import filecmp
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
428
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
429 self.admin=AdminTool()
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
430 self.install_init()
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
431
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
432 with captured_output() as (out, err):
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
433 sys.argv=['main', '-i', self.dirname, 'updateconfig',
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
434 self.dirname + "/config2.ini"]
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
435 ret = self.admin.main()
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
436
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
437 out = out.getvalue().strip()
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
438 print(out)
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
439 self.assertEqual(out, "")
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
440 self.assertTrue(os.path.isfile(self.dirname + "/config2.ini"))
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
441 # Autogenerated date header is different. Remove it
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
442 # so filecmp passes.
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
443 normalize_file(self.dirname + "/config2.ini",
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
444 [ '# Autogenerated at' ])
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
445 normalize_file(self.dirname + "/config.ini",
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
446 [ '# Autogenerated at' ])
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
447
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
448 self.assertTrue(filecmp.cmp(self.dirname + "/config.ini",
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
449 self.dirname + "/config2.ini"))
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
450
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
451 # Reopen the db closed by previous call
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
452 self.admin=AdminTool()
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
453
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
454 ### test replacement of old default value
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
455 replace_in_file(self.dirname + "/config.ini",
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
456 "= 2000000", "= 10000")
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
457 with captured_output() as (out, err):
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
458 sys.argv=['main', '-i', self.dirname, 'update',
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
459 self.dirname + "/config2.ini"]
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
460 ret = self.admin.main()
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
461
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
462 out = out.getvalue().strip()
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
463 print(out)
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
464 expected = "from old default of 10000 to new default of 2000000."
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
465
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
466 self.assertIn(expected, out)
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
467 self.assertTrue(os.path.isfile(self.dirname + "/config2.ini"))
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
468 self.assertEqual(find_in_file(self.dirname + "/config2.ini",
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
469 "^password_.*= 2000000$"),
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
470 "password_pbkdf2_default_rounds = 2000000")
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
471
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
472 # Reopen the db closed by previous call
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
473 self.admin=AdminTool()
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
474
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
475 ### test replacement of too small value
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
476 replace_in_file(self.dirname + "/config.ini",
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
477 "= 10000", "= 10001")
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
478 with captured_output() as (out, err):
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
479 sys.argv=['main', '-i', self.dirname, 'update',
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
480 self.dirname + "/config2.ini"]
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
481 ret = self.admin.main()
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
482
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
483 out = out.getvalue().strip()
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
484 print(out)
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
485 expected = ("Update 'password_pbkdf2_default_rounds' to a number "
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
486 "equal to or larger\nthan 2000000.")
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
487
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
488 self.assertIn(expected, out)
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
489 self.assertTrue(os.path.isfile(self.dirname + "/config2.ini"))
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
490 self.assertEqual(find_in_file(self.dirname + "/config2.ini",
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
491 "^password_.*= 10001$"),
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
492 "password_pbkdf2_default_rounds = 10001")
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
493
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
494
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
495 # Reopen the db closed by previous call
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
496 self.admin=AdminTool()
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
497
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
498 ### test no action if value is large enough
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
499 replace_in_file(self.dirname + "/config.ini",
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
500 "= 10001", "= 2000001")
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
501 with captured_output() as (out, err):
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
502 sys.argv=['main', '-i', self.dirname, 'update',
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
503 self.dirname + "/config2.ini"]
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
504 ret = self.admin.main()
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
505
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
506 out = out.getvalue().strip()
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
507 print(out)
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
508 expected = ""
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
509
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
510 self.assertEqual(expected, out)
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
511 self.assertTrue(os.path.isfile(self.dirname + "/config2.ini"))
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
512 self.assertEqual(find_in_file(self.dirname + "/config2.ini",
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
513 "^password_.*= 2000001$"),
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
514 "password_pbkdf2_default_rounds = 2000001")
ccb0e566e0be Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents: 7182
diff changeset
515
6188
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
516
6186
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
517 def testCliParse(self):
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
518 ''' Note the tests will fail if you run this under pdb.
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
519 the context managers capture the pdb prompts and this screws
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
520 up the stdout strings with (pdb) prefixed to the line.
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
521 '''
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
522 self.admin=AdminTool()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
523 self.install_init()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
524
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
525 # test partial command lookup fin -> calls find
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
526
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
527 with captured_output() as (out, err):
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
528 ''' assignedto is not a valid property=value, so
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
529 report error.
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
530 '''
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
531 sys.argv=['main', '-i', self.dirname, 'fin', 'issue',
6186
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
532 'assignedto=1']
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
533 ret = self.admin.main()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
534
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
535 out = out.getvalue().strip()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
536 print(out)
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
537 expected="[ '1' ]"
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
538 self.assertTrue(expected, out)
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
539
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
540 # Reopen the db closed by previous call
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
541 self.admin=AdminTool()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
542 # test multiple matches
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
543 with captured_output() as (out, err):
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
544 ''' assignedto is not a valid property=value, so
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
545 report error.
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
546 '''
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
547 sys.argv=['main', '-i', self.dirname, 'f', 'issue',
6186
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
548 'assignedto']
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
549 ret = self.admin.main()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
550
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
551 out = out.getvalue().strip()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
552 print(out)
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
553 expected='Multiple commands match "f": filter, find'
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
554 self.assertEqual(expected, out)
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
555
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
556 # Reopen the db closed by previous call
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
557 self.admin=AdminTool()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
558 # test broken command lookup xyzzy is not a valid command
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
559 with captured_output() as (out, err):
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
560 ''' assignedto is not a valid property=value, so
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
561 report error.
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
562 '''
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
563 sys.argv=['main', '-i', self.dirname, 'xyzzy', 'issue',
6186
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
564 'assignedto']
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
565 ret = self.admin.main()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
566
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
567 out = out.getvalue().strip()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
568 print(out)
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
569 expected=('Unknown command "xyzzy" '
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
570 '("help commands" for a list)')
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
571 self.assertEqual(expected, out)
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
572
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
573 # Reopen the db closed by previous call
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
574 self.admin=AdminTool()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
575 # test for keyword=value check
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
576 with captured_output() as (out, err):
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
577 ''' assignedto is not a valid property=value, so
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
578 report error.
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
579 '''
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
580 sys.argv=['main', '-i', self.dirname, 'find', 'issue',
6186
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
581 'assignedto']
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
582 ret = self.admin.main()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
583
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
584 out = out.getvalue().strip()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
585 print(out)
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
586 expected='Error: argument "assignedto" not propname=value'
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
587 self.assertTrue(expected in out)
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
588
6177
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
589 def testFilter(self):
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
590 ''' Note the tests will fail if you run this under pdb.
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
591 the context managers capture the pdb prompts and this screws
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
592 up the stdout strings with (pdb) prefixed to the line.
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
593 '''
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
594 self.admin=AdminTool()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
595 self.install_init()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
596
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
597 with captured_output() as (out, err):
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
598 sys.argv=['main', '-i', self.dirname, 'create', 'issue',
6177
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
599 'title="foo bar"', 'assignedto=admin' ]
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
600 ret = self.admin.main()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
601
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
602 out = out.getvalue().strip()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
603 print(out)
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
604 self.assertEqual(out, '1')
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
605
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
606 self.admin=AdminTool()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
607 with captured_output() as (out, err):
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
608 sys.argv=['main', '-i', self.dirname, 'create', 'issue',
6177
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
609 'title="bar foo bar"', 'assignedto=anonymous' ]
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
610 ret = self.admin.main()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
611
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
612 out = out.getvalue().strip()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
613 print(out)
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
614 self.assertEqual(out, '2')
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
615
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
616
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
617 # Reopen the db closed by previous filter call
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
618 # test string - one results, one value, substring
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
619 self.admin=AdminTool()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
620 with captured_output() as (out, err):
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
621 sys.argv=['main', '-i', self.dirname, 'filter', 'user',
6177
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
622 'username=admin']
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
623 ret = self.admin.main()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
624
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
625 out = out.getvalue().strip()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
626 print(out)
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
627 self.assertEqual(out, "['1']")
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
628
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
629 # Reopen the db closed by previous filter call
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
630 # test string - two results, two values, substring
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
631 self.admin=AdminTool()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
632 with captured_output() as (out, err):
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
633 ''' a,n should return all entries that have an a and n
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
634 so admin or anonymous
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
635 '''
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
636 sys.argv=['main', '-i', self.dirname, 'filter', 'user',
6177
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
637 'username=a,n']
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
638 ret = self.admin.main()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
639
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
640 out = out.getvalue().strip()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
641 print(out)
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
642 # out can be "['2', '1']" or "['1', '2']"
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
643 # so eval to real list so Equal can do a list compare
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
644 self.assertEqual(sorted(eval(out)), ['1', '2'])
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
645
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
646 # Reopen the db closed by previous filter call
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
647 # test string - one result, two values, substring
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
648 self.admin=AdminTool()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
649 with captured_output() as (out, err):
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
650 ''' a,y should return all entries that have an a and y
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
651 so anonymous
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
652 '''
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
653 sys.argv=['main', '-i', self.dirname, 'filter', 'user',
6177
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
654 'username=a,y']
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
655 ret = self.admin.main()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
656
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
657 out = out.getvalue().strip()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
658 print(out)
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
659 self.assertEqual(out, "['2']")
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
660
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
661 # Reopen the db closed by previous filter call
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
662 # test string - no results
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
663 self.admin=AdminTool()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
664 with captured_output() as (out, err):
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
665 ''' will return empty set as admin!=anonymous
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
666 '''
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
667 sys.argv=['main', '-i', self.dirname, 'filter', 'user',
6177
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
668 'username=admin,anonymous']
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
669 ret = self.admin.main()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
670
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
671 out = out.getvalue().strip()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
672 print(out)
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
673 self.assertEqual(out, "[]")
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
674
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
675 # Reopen the db closed by previous filter call
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
676 # test link using ids
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
677 self.admin=AdminTool()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
678 with captured_output() as (out, err):
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
679 sys.argv=['main', '-i', self.dirname, 'filter', 'issue',
6177
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
680 'assignedto=1,2']
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
681 ret = self.admin.main()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
682
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
683 out = out.getvalue().strip()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
684 print(out)
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
685 self.assertEqual(sorted(eval(out)), ['1', '2'])
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
686
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
687 # Reopen the db closed by previous filter call
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
688 # test link using names
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
689 self.admin=AdminTool()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
690 with captured_output() as (out, err):
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
691 ''' will return empty set as admin!=anonymous
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
692 '''
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
693 sys.argv=['main', '-i', self.dirname, 'filter', 'issue',
6177
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
694 'assignedto=admin,anonymous']
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
695 ret = self.admin.main()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
696
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
697 out = out.getvalue().strip()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
698 print(out)
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
699 self.assertEqual(sorted(eval(out)), ['1', '2'])
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
700
6250
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
701 # Reopen the db closed by previous filter call
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
702 #
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
703 # case: transitive property valid match
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
704 self.admin=AdminTool()
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
705 with captured_output() as (out, err):
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
706 sys.argv=['main', '-i', self.dirname, 'filter', 'issue',
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
707 'assignedto.roles=Anonymous']
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
708 ret = self.admin.main()
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
709
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
710 out = out.getvalue().strip()
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
711 print(out)
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
712 self.assertEqual(out, "['2']")
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
713
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
714 # Reopen the db closed by previous filter call
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
715 # self.admin=AdminTool()
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
716 # case: transitive propery invalid prop
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
717 self.admin=AdminTool()
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
718 with captured_output() as (out, err):
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
719 ''' assignedto is not a valid property=value, so
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
720 report error.
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
721 '''
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
722 sys.argv=['main', '-i', self.dirname, 'filter', 'issue',
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
723 'assignedto.badprop=Admin']
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
724 ret = self.admin.main()
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
725
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
726 out = out.getvalue().strip()
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
727 expected='Error: Class user has no property badprop in assignedto.badprop.'
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
728 print(out[0:len(expected)])
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
729 self.assertEqual(expected, out[0:len(expected)])
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
730
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
731 # Reopen the db closed by previous filter call
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
732 #
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
733 # case: transitive property invalid match
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
734 self.admin=AdminTool()
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
735 with captured_output() as (out, err):
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
736 sys.argv=['main', '-i', self.dirname,
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
737 'filter', 'issue',
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
738 'assignedto.username=NoNAme']
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
739 ret = self.admin.main()
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
740
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
741 out = out.getvalue().strip()
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
742 print("me: " + out)
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
743 print(err.getvalue().strip())
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
744 self.assertEqual(out, "[]")
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
745
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
746 # Reopen the db closed by previous filter call
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
747 #
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
748 # case: transitive property invalid match
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
749 self.admin=AdminTool()
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
750 with captured_output() as (out, err):
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
751 sys.argv=['main', '-i', self.dirname, '-c',
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
752 'filter', 'issue',
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
753 'assignedto.username=NoNAme']
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
754 ret = self.admin.main()
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
755
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
756 out = out.getvalue().strip()
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
757 print("me: " + out)
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
758 print(err.getvalue().strip())
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
759 self.assertEqual(out, "")
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
760
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
761 # Reopen the db closed by previous filter call
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
762 #
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
763 # case: transitive property invalid match
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
764 self.admin=AdminTool()
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
765 with captured_output() as (out, err):
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
766 sys.argv=['main', '-i', self.dirname, '-c',
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
767 'filter', 'issue',
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
768 'assignedto.username=A']
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
769 ret = self.admin.main()
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
770
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
771 out = out.getvalue().strip()
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
772 print("me: " + out)
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
773 print(err.getvalue().strip())
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
774 self.assertEqual(out, "1,2")
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
775
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
776 # Reopen the db closed by previous filter call
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
777 #
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
778 # case: transitive property invalid match
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
779 self.admin=AdminTool()
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
780 with captured_output() as (out, err):
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
781 sys.argv=['main', '-i', self.dirname, '-s',
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
782 'filter', 'issue',
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
783 'assignedto.username=A']
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
784 ret = self.admin.main()
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
785
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
786 out = out.getvalue().strip()
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
787 print("me: " + out)
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
788 print(err.getvalue().strip())
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
789 self.assertEqual(out, "1 2")
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
790
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
791 # Reopen the db closed by previous filter call
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
792 #
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
793 # case: transitive property invalid match
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
794 self.admin=AdminTool()
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
795 with captured_output() as (out, err):
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
796 sys.argv=['main', '-i', self.dirname, '-S', ':',
6251
b303db7f384f Test designator code path
John Rouillard <rouilj@ieee.org>
parents: 6250
diff changeset
797 '-d', 'filter', 'issue',
6250
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
798 'assignedto.username=A']
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
799 ret = self.admin.main()
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
800
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
801 out = out.getvalue().strip()
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
802 print("me: " + out)
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
803 print(err.getvalue().strip())
6251
b303db7f384f Test designator code path
John Rouillard <rouilj@ieee.org>
parents: 6250
diff changeset
804 self.assertEqual(out, "issue1:issue2")
6250
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
805
7254
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
806 def testPragma_reopen_tracker(self):
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
807 """test that _reopen_tracker works.
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
808 """
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
809 if self.backend not in ['anydbm']:
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
810 self.skipTest("For speed only run test with anydbm.")
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
811
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
812 orig_input = AdminTool.my_input
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
813
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
814 # must set verbose to see _reopen_tracker hidden setting.
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
815 # and to get "Reopening tracker" verbose log output
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
816 inputs = iter(["pragma verbose=true", "pragma list", "quit"])
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
817 AdminTool.my_input = lambda _self, _prompt: next(inputs)
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
818
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
819 self.install_init()
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
820 self.admin=AdminTool()
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
821 sys.argv=['main', '-i', self.dirname]
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
822
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
823 with captured_output() as (out, err):
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
824 ret = self.admin.main()
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
825
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
826 out = out.getvalue().strip().split('\n')
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
827
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
828 print(ret)
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
829 self.assertTrue(ret == 0)
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
830 expected = ' _reopen_tracker=False'
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
831 self.assertIn(expected, out)
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
832 self.assertIn('descriptions...', out[-1])
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
833 self.assertNotIn('Reopening tracker', out)
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
834
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
835 # -----
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
836 inputs = iter(["pragma verbose=true", "pragma _reopen_tracker=True",
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
837 "pragma list", "quit"])
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
838 AdminTool.my_input = lambda _self, _prompt: next(inputs)
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
839
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
840 self.install_init()
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
841 self.admin=AdminTool()
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
842 sys.argv=['main', '-i', self.dirname]
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
843
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
844 with captured_output() as (out, err):
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
845 ret = self.admin.main()
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
846
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
847 out = out.getvalue().strip().split('\n')
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
848
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
849 print(ret)
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
850 self.assertTrue(ret == 0)
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
851 self.assertEqual('Reopening tracker', out[2])
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
852 expected = ' _reopen_tracker=True'
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
853 self.assertIn(expected, out)
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
854
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
855 # -----
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
856 AdminTool.my_input = orig_input
af870e295b46 add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents: 7252
diff changeset
857
7252
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
858 def testPragma(self):
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
859 """Uses interactive mode since pragmas only apply when using multiple
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
860 commands.
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
861 """
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
862 if self.backend not in ['anydbm']:
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
863 self.skipTest("For speed only run test with anydbm.")
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
864
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
865 orig_input = AdminTool.my_input
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
866
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
867 for i in ["oN", "1", "yeS", "True"]:
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
868 inputs = iter(["pragma verbose=%s" % i, "pragma list", "quit"])
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
869 AdminTool.my_input = lambda _self, _prompt: next(inputs)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
870
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
871 self.install_init()
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
872 self.admin=AdminTool()
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
873 sys.argv=['main', '-i', self.dirname]
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
874
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
875 with captured_output() as (out, err):
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
876 ret = self.admin.main()
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
877
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
878 out = out.getvalue().strip().split('\n')
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
879
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
880 print(ret)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
881 self.assertTrue(ret == 0)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
882 expected = ' verbose=True'
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
883 self.assertIn(expected, out)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
884 self.assertIn('descriptions...', out[-1])
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
885
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
886 # -----
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
887 for i in ["oFf", "0", "NO", "FalSe"]:
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
888 inputs = iter(["pragma verbose=true", "pragma verbose=%s" % i,
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
889 "pragma list", "quit"])
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
890 AdminTool.my_input = lambda _self, _prompt: next(inputs)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
891
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
892 self.install_init()
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
893 self.admin=AdminTool()
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
894 sys.argv=['main', '-i', self.dirname]
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
895
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
896 with captured_output() as (out, err):
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
897 ret = self.admin.main()
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
898
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
899 out = out.getvalue().strip().split('\n')
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
900
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
901 print(ret)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
902 self.assertTrue(ret == 0)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
903 expected = ' verbose=False'
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
904 self.assertIn(expected, out)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
905
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
906 # ----- test syntax errors
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
907 inputs = iter(["pragma", "pragma arg",
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
908 "pragma foo=3","quit"])
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
909 AdminTool.my_input = lambda _self, _prompt: next(inputs)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
910
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
911 self.install_init()
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
912 self.admin=AdminTool()
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
913 sys.argv=['main', '-i', self.dirname]
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
914
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
915 with captured_output() as (out, err):
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
916 ret = self.admin.main()
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
917
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
918 out = out.getvalue().strip().split('\n')
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
919
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
920 print(ret)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
921 self.assertTrue(ret == 0)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
922 expected = 'Error: Not enough arguments supplied'
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
923 self.assertIn(expected, out)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
924 expected = 'Error: Argument must be setting=value, was given: arg.'
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
925 self.assertIn(expected, out)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
926 expected = 'Error: Unknown setting foo.'
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
927 self.assertIn(expected, out)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
928
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
929 # -----
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
930 inputs = iter(["pragma verbose=foo", "quit"])
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
931 AdminTool.my_input = lambda _self, _prompt: next(inputs)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
932
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
933 self.install_init()
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
934 self.admin=AdminTool()
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
935 sys.argv=['main', '-i', self.dirname]
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
936
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
937 with captured_output() as (out, err):
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
938 ret = self.admin.main()
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
939
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
940 out = out.getvalue().strip().split('\n')
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
941
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
942 print(ret)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
943 self.assertTrue(ret == 0)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
944 expected = 'Error: Incorrect value for boolean setting verbose: foo.'
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
945 self.assertIn(expected, out)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
946
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
947 # -----
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
948 inputs = iter(["pragma verbose=on", "pragma _inttest=5",
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
949 "pragma list", "quit"])
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
950 AdminTool.my_input = lambda _self, _prompt: next(inputs)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
951
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
952 self.install_init()
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
953 self.admin=AdminTool()
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
954 sys.argv=['main', '-i', self.dirname]
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
955
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
956 with captured_output() as (out, err):
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
957 ret = self.admin.main()
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
958
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
959 out = out.getvalue().strip().split('\n')
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
960
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
961 print(ret)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
962 self.assertTrue(ret == 0)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
963 expected = ' _inttest=5'
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
964 self.assertIn(expected, out)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
965 self.assertIn('descriptions...', out[-1])
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
966
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
967
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
968 # -----
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
969 inputs = iter(["pragma verbose=on", "pragma _inttest=fred",
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
970 "pragma list", "quit"])
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
971 AdminTool.my_input = lambda _self, _prompt: next(inputs)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
972
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
973 self.install_init()
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
974 self.admin=AdminTool()
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
975 sys.argv=['main', '-i', self.dirname]
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
976
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
977 with captured_output() as (out, err):
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
978 ret = self.admin.main()
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
979
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
980 out = out.getvalue().strip().split('\n')
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
981
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
982 print(ret)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
983 self.assertTrue(ret == 0)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
984 expected = 'Error: Incorrect value for integer setting _inttest: fred.'
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
985 self.assertIn(expected, out)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
986 self.assertIn('descriptions...', out[-1])
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
987
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
988 # -----
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
989 inputs = iter(["pragma indexer_backend=whoosh", "pragma list",
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
990 "quit"])
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
991 AdminTool.my_input = lambda _self, _prompt: next(inputs)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
992
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
993 self.install_init()
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
994 self.admin=AdminTool()
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
995 sys.argv=['main', '-i', self.dirname]
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
996
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
997 with captured_output() as (out, err):
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
998 ret = self.admin.main()
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
999
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1000 out = out.getvalue().strip().split('\n')
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1001
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1002 print(ret)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1003 expected = ' indexer_backend=whoosh'
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1004 self.assertIn(expected, out)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1005
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1006 # -----
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1007 inputs = iter(["pragma _floattest=4.5", "quit"])
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1008 AdminTool.my_input = lambda _self, _prompt: next(inputs)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1009
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1010 self.install_init()
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1011 self.admin=AdminTool()
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1012 sys.argv=['main', '-i', self.dirname]
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1013
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1014 with captured_output() as (out, err):
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1015 ret = self.admin.main()
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1016
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1017 out = out.getvalue().strip().split('\n')
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1018
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1019 print(ret)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1020 expected = 'Error: Internal error: pragma can not handle values of type: float'
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1021 self.assertIn(expected, out)
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1022
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1023 # -----
9c067ed4568b add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 7205
diff changeset
1024 AdminTool.my_input = orig_input
6250
95183d73ac64 issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents: 6199
diff changeset
1025
6199
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1026 def disabletestHelpInitopts(self):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1027
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1028 ''' Note the tests will fail if you run this under pdb.
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1029 the context managers capture the pdb prompts and this screws
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1030 up the stdout strings with (pdb) prefixed to the line.
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1031 '''
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1032 self.install_init()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1033 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1034
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1035 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1036 sys.argv=['main', '-i', self.dirname, 'help', 'initopts']
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1037 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1038
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1039 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1040 expected = [
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1041 'Templates: minimal, jinja2, classic, responsive, devel',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1042 'Back ends: anydbm, sqlite'
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1043 ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1044 print(out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1045 self.assertTrue(expected[0] in out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1046 self.assertTrue("Back ends:" in out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1047
6393
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1048 def testSecurity(self):
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1049 ''' Note the tests will fail if you run this under pdb.
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1050 the context managers capture the pdb prompts and this screws
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1051 up the stdout strings with (pdb) prefixed to the line.
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1052 '''
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1053 self.install_init()
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1054 self.admin=AdminTool()
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1055
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1056 with captured_output() as (out, err):
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1057 sys.argv=['main', '-i', self.dirname, 'security' ]
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1058 ret = self.admin.main()
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1059
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1060 result = """New Web users get the Role "User"
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1061 New Email users get the Role "User"
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1062 Role "admin":
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1063 User may create everything (Create)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1064 User may edit everything (Edit)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1065 User may restore everything (Restore)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1066 User may retire everything (Retire)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1067 User may view everything (View)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1068 User may access the web interface (Web Access)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1069 User may access the rest interface (Rest Access)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1070 User may access the xmlrpc interface (Xmlrpc Access)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1071 User may manipulate user Roles through the web (Web Roles)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1072 User may use the email interface (Email Access)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1073 Role "anonymous":
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1074 User may access the web interface (Web Access)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1075 User is allowed to register new user (Register for "user" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1076 User is allowed to access issue (View for "issue" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1077 User is allowed to access file (View for "file" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1078 User is allowed to access msg (View for "msg" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1079 User is allowed to access keyword (View for "keyword" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1080 User is allowed to access priority (View for "priority" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1081 User is allowed to access status (View for "status" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1082 (Search for "user" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1083 Role "user":
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1084 User may access the web interface (Web Access)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1085 User may use the email interface (Email Access)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1086 User may access the rest interface (Rest Access)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1087 User may access the xmlrpc interface (Xmlrpc Access)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1088 User is allowed to access issue (View for "issue" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1089 User is allowed to edit issue (Edit for "issue" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1090 User is allowed to create issue (Create for "issue" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1091 User is allowed to access file (View for "file" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1092 User is allowed to edit file (Edit for "file" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1093 User is allowed to create file (Create for "file" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1094 User is allowed to access msg (View for "msg" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1095 User is allowed to edit msg (Edit for "msg" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1096 User is allowed to create msg (Create for "msg" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1097 User is allowed to access keyword (View for "keyword" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1098 User is allowed to edit keyword (Edit for "keyword" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1099 User is allowed to create keyword (Create for "keyword" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1100 User is allowed to access priority (View for "priority" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1101 User is allowed to access status (View for "status" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1102 (View for "user": ('id', 'organisation', 'phone', 'realname', 'timezone', 'username') only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1103 User is allowed to view their own user details (View for "user" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1104 User is allowed to edit their own user details (Edit for "user": ('username', 'password', 'address', 'realname', 'phone', 'organisation', 'alternate_addresses', 'queries', 'timezone') only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1105 User is allowed to view their own and public queries (View for "query" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1106 (Search for "query" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1107 User is allowed to edit their queries (Edit for "query" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1108 User is allowed to retire their queries (Retire for "query" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1109 User is allowed to restore their queries (Restore for "query" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1110 User is allowed to create queries (Create for "query" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1111 """
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1112 print(out.getvalue())
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1113
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1114 self.assertEqual(result, out.getvalue())
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1115 self.assertEqual(ret, 0)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1116
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1117 def testSecurityInvalidAttribute(self):
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1118 ''' Test with an invalid attribute.
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1119 Note the tests will fail if you run this under pdb.
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1120 the context managers capture the pdb prompts and this screws
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1121 up the stdout strings with (pdb) prefixed to the line.
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1122 '''
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1123 self.maxDiff = None # we want full diff
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1124
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1125 self.install_init()
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1126
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1127 # edit in an invalid attribute/property
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1128 with open(self.dirname + "/schema.py", "r+") as f:
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1129 d = f.readlines()
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1130 f.seek(0)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1131 for i in d:
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1132 if "organisation" in i:
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1133 i = i.replace("'id', 'organisation'","'id', 'organization'")
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1134 f.write(i)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1135 f.truncate()
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1136
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1137 self.admin=AdminTool()
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1138
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1139 with captured_output() as (out, err):
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1140 sys.argv=['main', '-i', self.dirname, 'security' ]
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1141 ret = self.admin.main()
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1142
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1143 result = """New Web users get the Role "User"
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1144 New Email users get the Role "User"
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1145 Role "admin":
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1146 User may create everything (Create)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1147 User may edit everything (Edit)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1148 User may restore everything (Restore)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1149 User may retire everything (Retire)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1150 User may view everything (View)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1151 User may access the web interface (Web Access)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1152 User may access the rest interface (Rest Access)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1153 User may access the xmlrpc interface (Xmlrpc Access)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1154 User may manipulate user Roles through the web (Web Roles)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1155 User may use the email interface (Email Access)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1156 Role "anonymous":
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1157 User may access the web interface (Web Access)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1158 User is allowed to register new user (Register for "user" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1159 User is allowed to access issue (View for "issue" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1160 User is allowed to access file (View for "file" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1161 User is allowed to access msg (View for "msg" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1162 User is allowed to access keyword (View for "keyword" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1163 User is allowed to access priority (View for "priority" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1164 User is allowed to access status (View for "status" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1165 (Search for "user" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1166 Role "user":
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1167 User may access the web interface (Web Access)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1168 User may use the email interface (Email Access)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1169 User may access the rest interface (Rest Access)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1170 User may access the xmlrpc interface (Xmlrpc Access)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1171 User is allowed to access issue (View for "issue" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1172 User is allowed to edit issue (Edit for "issue" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1173 User is allowed to create issue (Create for "issue" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1174 User is allowed to access file (View for "file" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1175 User is allowed to edit file (Edit for "file" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1176 User is allowed to create file (Create for "file" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1177 User is allowed to access msg (View for "msg" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1178 User is allowed to edit msg (Edit for "msg" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1179 User is allowed to create msg (Create for "msg" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1180 User is allowed to access keyword (View for "keyword" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1181 User is allowed to edit keyword (Edit for "keyword" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1182 User is allowed to create keyword (Create for "keyword" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1183 User is allowed to access priority (View for "priority" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1184 User is allowed to access status (View for "status" only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1185 (View for "user": ('id', 'organization', 'phone', 'realname', 'timezone', 'username') only)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1186
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1187 **Invalid properties for user: ['organization']
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1188
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1189 """
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1190 print(out.getvalue())
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1191
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1192 self.assertEqual(result, out.getvalue())
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1193 self.assertEqual(ret, 1)
51a1a9b0f567 - issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents: 6332
diff changeset
1194
6181
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1195 def testSet(self):
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1196 ''' Note the tests will fail if you run this under pdb.
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1197 the context managers capture the pdb prompts and this screws
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1198 up the stdout strings with (pdb) prefixed to the line.
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1199 '''
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1200 self.install_init()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1201 self.admin=AdminTool()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1202
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1203 with captured_output() as (out, err):
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
1204 sys.argv=['main', '-i', self.dirname, 'create', 'issue',
6181
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1205 'title="foo bar"', 'assignedto=admin' ]
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1206 ret = self.admin.main()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1207
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1208 out = out.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1209 print(out)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1210 self.assertEqual(out, '1')
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1211
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1212 self.admin=AdminTool()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1213 with captured_output() as (out, err):
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
1214 sys.argv=['main', '-i', self.dirname, 'create', 'issue',
6181
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1215 'title="bar foo bar"', 'assignedto=anonymous' ]
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1216 ret = self.admin.main()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1217
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1218 out = out.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1219 print(out)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1220 self.assertEqual(out, '2')
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1221
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1222 self.admin=AdminTool()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1223 with captured_output() as (out, err):
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
1224 sys.argv=['main', '-i', self.dirname, 'set', 'issue2', 'title="new title"']
6181
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1225 ret = self.admin.main()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1226
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1227 out = out.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1228 err = err.getvalue().strip()
6332
6a6b4651be1f Use server-side cursor for postgres in some cases
Ralf Schlatterbeck <rsc@runtux.com>
parents: 6251
diff changeset
1229 self.assertEqual(out, '')
6a6b4651be1f Use server-side cursor for postgres in some cases
Ralf Schlatterbeck <rsc@runtux.com>
parents: 6251
diff changeset
1230 self.assertEqual(err, '')
6181
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1231
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1232 self.admin=AdminTool()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1233 with captured_output() as (out, err):
6199
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1234 sys.argv=['main', '-i', self.dirname, 'set', 'issue2',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1235 'tile="new title"']
6181
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1236 ret = self.admin.main()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1237
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1238 expected_err = "Error: 'tile' is not a property of issue"
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1239
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1240 out = out.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1241 err = err.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1242 self.assertEqual(out.index(expected_err), 0)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1243 self.assertEqual(len(err), 0)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1244
6199
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1245 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1246 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1247 sys.argv=['main', '-i', self.dirname, 'set', 'issue2']
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1248 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1249
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1250 expected_err = "Error: Not enough arguments supplied"
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1251
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1252 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1253 err = err.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1254 self.assertEqual(out.index(expected_err), 0)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1255 self.assertEqual(len(err), 0)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1256
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1257
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1258 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1259 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1260 sys.argv=['main', '-i', self.dirname, 'set',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1261 'issue2,issue1,issue', "status=1" ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1262 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1263
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1264 expected_err = 'Error: "issue" not a node designator'
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1265
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1266 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1267 err = err.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1268 self.assertEqual(out.index(expected_err), 0)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1269 self.assertEqual(len(err), 0)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1270
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1271 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1272 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1273 sys.argv=['main', '-i', self.dirname, 'set',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1274 'issue2,issue1,user2', "status=1" ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1275 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1276
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1277 expected_err = "Error: 'status' is not a property of user"
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1278
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1279 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1280 err = err.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1281 print(out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1282 print(expected_err)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1283 print(err)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1284 self.assertEqual(out.index(expected_err), 0)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1285 self.assertEqual(len(err), 0)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1286
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1287 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1288 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1289 sys.argv=['main', '-i', self.dirname, 'set',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1290 'issue2,issue1,issue1000', "status=1" ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1291 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1292
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1293 expected_err = 'Error: no such issue 1000'
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1294
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1295 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1296 err = err.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1297 self.assertEqual(out.index(expected_err), 0)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1298 self.assertEqual(len(err), 0)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1299
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1300 def testSetOnClass(self):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1301 ''' Note the tests will fail if you run this under pdb.
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1302 the context managers capture the pdb prompts and this screws
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1303 up the stdout strings with (pdb) prefixed to the line.
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1304 '''
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1305 self.install_init()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1306
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1307 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1308 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1309 sys.argv=['main', '-i', self.dirname, 'create', 'issue',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1310 'title="foo bar"', 'assignedto=admin' ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1311 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1312
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1313 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1314 print(out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1315 self.assertEqual(out, '1')
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1316
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1317 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1318 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1319 sys.argv=['main', '-i', self.dirname, 'create', 'issue',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1320 'title="bar foo bar"', 'assignedto=anonymous' ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1321 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1322
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1323 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1324 print(out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1325 self.assertEqual(out, '2')
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1326
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1327 # Run this test in a separate test.
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1328 # It can cause a database timeout/resource
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1329 # unavailable error for anydbm when run with other tests.
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1330 # Not sure why.
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1331 # Set assignedto=2 for all issues
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1332 ## verify that issue 1 and 2 are assigned to user1 and user2
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1333 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1334 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1335 sys.argv=['main', '-i', self.dirname, 'table', 'issue',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1336 'assignedto']
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1337 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1338
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1339 expected = "Assignedto\n1 \n2"
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1340 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1341 err = err.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1342 self.assertEqual(out, expected)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1343 self.assertEqual(len(err), 0)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1344 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1345 # do the set
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1346 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1347 sys.argv=['main', '-i', self.dirname, 'set', 'issue',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1348 'assignedto=2']
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1349 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1350
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1351 expected_err = ""
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1352
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1353 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1354 err = err.getvalue().strip()
6332
6a6b4651be1f Use server-side cursor for postgres in some cases
Ralf Schlatterbeck <rsc@runtux.com>
parents: 6251
diff changeset
1355 self.assertEqual(out, '')
6a6b4651be1f Use server-side cursor for postgres in some cases
Ralf Schlatterbeck <rsc@runtux.com>
parents: 6251
diff changeset
1356 self.assertEqual(err, '')
6199
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1357
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1358 ## verify that issue 1 and 2 are assigned to user2 and user2
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1359 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1360 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1361 sys.argv=['main', '-i', self.dirname, 'table', 'issue',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1362 'assignedto']
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1363 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1364
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1365 expected = "Assignedto\n2 \n2"
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1366 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1367 err = err.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1368 self.assertEqual(out, expected)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1369 self.assertEqual(len(err), 0)
6181
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
1370
6176
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
1371 def testSpecification(self):
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
1372 ''' Note the tests will fail if you run this under pdb.
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
1373 the context managers capture the pdb prompts and this screws
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
1374 up the stdout strings with (pdb) prefixed to the line.
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
1375 '''
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
1376 self.install_init()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
1377 self.admin=AdminTool()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
1378
6178
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
1379 spec= [ 'username: <roundup.hyperdb.String> (key property)',
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
1380 'alternate_addresses: <roundup.hyperdb.String>',
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
1381 'realname: <roundup.hyperdb.String>',
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
1382 'roles: <roundup.hyperdb.String>',
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
1383 'organisation: <roundup.hyperdb.String>',
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
1384 'queries: <roundup.hyperdb.Multilink to "query">',
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
1385 'phone: <roundup.hyperdb.String>',
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
1386 'address: <roundup.hyperdb.String>',
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
1387 'timezone: <roundup.hyperdb.String>',
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
1388 'password: <roundup.hyperdb.Password>',
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
1389 ]
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
1390
6176
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
1391 with captured_output() as (out, err):
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
1392 sys.argv=['main', '-i', self.dirname, 'specification', 'user']
6176
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
1393 ret = self.admin.main()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
1394
6178
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
1395 outlist = out.getvalue().strip().split("\n")
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
1396 print(outlist)
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
1397 self.assertEqual(sorted(outlist), sorted(spec))
5713
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
1398
6430
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1399 def testRetireRestore(self):
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1400 ''' Note the tests will fail if you run this under pdb.
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1401 the context managers capture the pdb prompts and this screws
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1402 up the stdout strings with (pdb) prefixed to the line.
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1403 '''
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1404 # create user1 at id 3
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1405 self.install_init()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1406 self.admin=AdminTool()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1407 with captured_output() as (out, err):
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1408 sys.argv=['main', '-i', self.dirname, 'create', 'user',
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1409 'username=user1', 'address=user1' ]
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1410 ret = self.admin.main()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1411
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1412 out = out.getvalue().strip()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1413 print(out)
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1414 self.assertEqual(out, '3')
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1415
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1416 # retire user1 at id 3
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1417 self.admin=AdminTool()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1418 with captured_output() as (out, err):
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1419 sys.argv=['main', '-i', self.dirname, 'retire', 'user3']
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1420 ret = self.admin.main()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1421 out = out.getvalue().strip()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1422 print(out)
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1423 self.assertEqual(out, '')
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1424
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1425 # create new user1 at id 4 - note need unique address to succeed.
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1426 self.admin=AdminTool()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1427 with captured_output() as (out, err):
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1428 sys.argv=['main', '-i', self.dirname, 'create', 'user',
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1429 'username=user1', 'address=user1a' ]
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1430 ret = self.admin.main()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1431
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1432 out = out.getvalue().strip()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1433 print(out)
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1434 self.assertEqual(out, '4')
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1435
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1436 # fail to restore old user1 at id 3
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1437 self.admin=AdminTool()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1438 with captured_output() as (out, err):
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1439 sys.argv=['main', '-i', self.dirname, 'restore', 'user3']
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1440 ret = self.admin.main()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1441 out = out.getvalue().strip()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1442 print(out)
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1443 self.assertIn('Error: Key property (username) of retired node clashes with existing one (user1)', out)
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1444
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1445 # verify that user4 is listed
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1446 self.admin=AdminTool()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1447 with captured_output() as (out, err):
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1448 sys.argv=['main', '-i', self.dirname, 'list', 'user']
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1449 ret = self.admin.main()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1450 out = out.getvalue().strip()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1451 print(out)
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1452 expected="1: admin\n 2: anonymous\n 4: user1"
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1453 self.assertEqual(out, expected)
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1454
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1455 # retire user4
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1456 self.admin=AdminTool()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1457 with captured_output() as (out, err):
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1458 sys.argv=['main', '-i', self.dirname, 'retire', 'user4']
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1459 ret = self.admin.main()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1460 out = out.getvalue().strip()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1461 print(out)
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1462 self.assertEqual(out, '')
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1463
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1464 # now we can restore user3
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1465 self.admin=AdminTool()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1466 with captured_output() as (out, err):
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1467 sys.argv=['main', '-i', self.dirname, 'restore', 'user3']
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1468 ret = self.admin.main()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1469 out = out.getvalue().strip()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1470 print(out)
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1471 self.assertEqual(out, '')
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1472
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1473 # verify that user3 is listed
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1474 self.admin=AdminTool()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1475 with captured_output() as (out, err):
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1476 sys.argv=['main', '-i', self.dirname, 'list', 'user']
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1477 ret = self.admin.main()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1478 out = out.getvalue().strip()
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1479 print(out)
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1480 expected="1: admin\n 2: anonymous\n 3: user1"
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1481 self.assertEqual(out, expected)
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1482
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1483
ff4ab763f47c issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents: 6393
diff changeset
1484
6199
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1485 def testTable(self):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1486 ''' Note the tests will fail if you run this under pdb.
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1487 the context managers capture the pdb prompts and this screws
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1488 up the stdout strings with (pdb) prefixed to the line.
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1489 '''
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1490 self.install_init()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1491 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1492
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1493 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1494 sys.argv=['main', '-i', self.dirname, 'table' ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1495 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1496
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1497 expected = 'Error: Not enough arguments supplied'
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1498
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1499 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1500 print(out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1501 print(expected)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1502 self.assertTrue(expected in out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1503 ####
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1504
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1505 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1506
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1507 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1508 sys.argv=['main', '-i', self.dirname, 'table',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1509 'id,realname,username' ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1510 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1511
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1512 expected = 'Error: no such class "id,realname,username"'
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1513
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1514 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1515 print(out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1516 print(expected)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1517 self.assertTrue(expected in out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1518
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1519 ####
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1520 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1521
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1522 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1523 sys.argv=['main', '-i', self.dirname, 'table', 'user',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1524 'id,realname,username:4:3' ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1525 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1526 expected = 'Error: "username:4:3" not name:width'
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1527
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1528 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1529 print(out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1530 print(expected)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1531 self.assertTrue(expected in out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1532
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1533 ####
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1534 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1535
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1536 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1537 sys.argv=['main', '-i', self.dirname, 'table', 'user',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1538 'id,realname,title:4' ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1539 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1540 expected = 'Error: user has no property "title"'
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1541
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1542 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1543 print(out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1544 print(expected)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1545 self.assertTrue(expected in out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1546
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1547 ####
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1548 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1549
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1550 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1551 sys.argv=['main', '-i', self.dirname, 'table', 'user',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1552 'id,realname,username:' ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1553 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1554
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1555 # note whitespace matters. trailing spaces on lines 1 and 2
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1556 expected = """Id Realname Username
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1557 1 None admin
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1558 2 None anonymou"""
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1559
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1560 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1561 print(out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1562 print(expected)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1563 self.assertEqual(out, expected)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1564
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1565 ####
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1566 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1567
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1568 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1569 sys.argv=['main', '-i', self.dirname, 'table', 'user',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1570 'id,realname,username' ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1571 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1572
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1573 # note whitespace matters. trailing spaces on lines 1 and 2
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1574 expected = """Id Realname Username
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1575 1 None admin
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1576 2 None anonymous"""
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1577
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1578 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1579 print(out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1580 print(expected)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1581 self.assertEqual(out, expected)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1582
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1583 ####
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1584 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1585
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1586 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1587 sys.argv=['main', '-i', self.dirname, 'table', 'user',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1588 'id:4,realname:2,username:3' ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1589 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1590
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1591 # note whitespace matters. trailing spaces on lines 1 and 2
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1592 expected = """Id Realname Username
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1593 1 No adm
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1594 2 No ano"""
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1595
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1596 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1597 print(out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1598 print(expected)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1599 self.assertEqual(out, expected)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
1600
6957
f924af12ef50 issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents: 6430
diff changeset
1601 def testTemplates(self):
f924af12ef50 issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents: 6430
diff changeset
1602
f924af12ef50 issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents: 6430
diff changeset
1603 self.install_init()
f924af12ef50 issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents: 6430
diff changeset
1604 self.admin=AdminTool()
f924af12ef50 issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents: 6430
diff changeset
1605
f924af12ef50 issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents: 6430
diff changeset
1606 with captured_output() as (out, err):
6958
e54a2db40a9e check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents: 6957
diff changeset
1607 # command does not require a tracker home. use missing zZzZ
e54a2db40a9e check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents: 6957
diff changeset
1608 # directory to cause error if that changes
6957
f924af12ef50 issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents: 6430
diff changeset
1609 sys.argv=['main', '-i', "zZzZ", 'templates' ]
f924af12ef50 issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents: 6430
diff changeset
1610 ret = self.admin.main()
f924af12ef50 issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents: 6430
diff changeset
1611
f924af12ef50 issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents: 6430
diff changeset
1612 out = out.getvalue().strip()
f924af12ef50 issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents: 6430
diff changeset
1613
6958
e54a2db40a9e check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents: 6957
diff changeset
1614 # all 5 standard trackers should be found
6957
f924af12ef50 issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents: 6430
diff changeset
1615 for tracker in ['Name: classic\nPath:',
f924af12ef50 issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents: 6430
diff changeset
1616 'Name: devel\nPath:',
f924af12ef50 issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents: 6430
diff changeset
1617 'Name: jinja2\nPath:',
f924af12ef50 issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents: 6430
diff changeset
1618 'Name: minimal\nPath:',
f924af12ef50 issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents: 6430
diff changeset
1619 'Name: responsive\nPath:']:
f924af12ef50 issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents: 6430
diff changeset
1620 self.assertIn(tracker, out)
5713
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
1621
6958
e54a2db40a9e check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents: 6957
diff changeset
1622 with captured_output() as (out, err):
e54a2db40a9e check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents: 6957
diff changeset
1623 # command does not require a tracker home. use missing zZzZ
e54a2db40a9e check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents: 6957
diff changeset
1624 # directory to cause error if that changes
e54a2db40a9e check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents: 6957
diff changeset
1625 sys.argv=['main', '-i', "zZzZ", 'templates', 'trace_search' ]
e54a2db40a9e check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents: 6957
diff changeset
1626 ret = self.admin.main()
e54a2db40a9e check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents: 6957
diff changeset
1627
e54a2db40a9e check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents: 6957
diff changeset
1628 out = out.getvalue().strip()
e54a2db40a9e check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents: 6957
diff changeset
1629
e54a2db40a9e check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents: 6957
diff changeset
1630 expected = "/*\n"
e54a2db40a9e check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents: 6957
diff changeset
1631 self.assertIn(expected, out)
e54a2db40a9e check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents: 6957
diff changeset
1632
5713
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
1633 class anydbmAdminTest(AdminTest, unittest.TestCase):
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
1634 backend = 'anydbm'
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
1635
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
1636
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
1637 @skip_mysql
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
1638 class mysqlAdminTest(AdminTest, unittest.TestCase):
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
1639 backend = 'mysql'
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
1640
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
1641
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
1642 class sqliteAdminTest(AdminTest, unittest.TestCase):
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
1643 backend = 'sqlite'
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
1644
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
1645
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
1646 @skip_postgresql
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
1647 class postgresqlAdminTest(AdminTest, unittest.TestCase):
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
1648 backend = 'postgresql'

Roundup Issue Tracker: http://roundup-tracker.org/