Mercurial > p > roundup > code
annotate test/test_admin.py @ 7392:bd6523c84a95
Fix test failure caused by making genconfig trackerless
When I removed the need to have a tracker for genconfig, I broke a
couple of tests. The breakage was hidden by a bad workflow.
This change allows the tests to pass and refactors reporting of
UsageError exceptions in admin.py.
It also adds a test for failure in install command as there is a test
case for it and this test tests the refactor.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Wed, 24 May 2023 11:25:47 -0400 |
| parents | af870e295b46 |
| children | 312d52305583 |
| 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 | 236 self.admin=AdminTool() |
| 237 with captured_output() as (out, err): | |
| 238 sys.argv=['main', '-i', self.dirname, 'get', 'title', 'issue'] | |
| 239 ret = self.admin.main() | |
| 240 | |
| 241 expected_err = 'Error: "issue" not a node designator' | |
| 242 | |
| 243 self.assertEqual(ret, 1) | |
| 244 out = out.getvalue().strip() | |
| 245 err = err.getvalue().strip() | |
| 246 self.assertEqual(out.index(expected_err), 0) | |
| 247 self.assertEqual(len(err), 0) | |
| 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 |
|
7392
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
258 self.admin=AdminTool() |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
259 with captured_output() as (out, err): |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
260 sys.argv=['main', '-i', '/tmp/noSuchDirectory/nodir', 'install', 'classic', self.backend] |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
261 ret = self.admin.main() |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
262 |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
263 out = out.getvalue().strip() |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
264 print(ret) |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
265 print(out) |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
266 self.assertEqual(ret, 1) |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
267 self.assertIn('Error: Instance home parent directory ' |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
268 '"/tmp/noSuchDirectory" does not exist', out) |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
269 |
|
5762
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
270 def testInitWithConfig_ini(self): |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
271 from roundup.configuration import CoreConfig |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
272 self.admin=AdminTool() |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
273 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
|
274 # create a config_ini.ini file in classic template |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
275 templates=self.admin.listTemplates() |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
276 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
|
277 config_ini_path = templates['classic']['path'] + '/config_ini.ini' |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
278 config_ini_file = open(config_ini_path, "w") |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
279 config_ini_file.write(config_ini_content) |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
280 config_ini_file.close() |
|
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 try: |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
283 ret = self.admin.main() |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
284 finally: |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
285 try: |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
286 # ignore file not found |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
287 os.remove(config_ini_path) |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
288 except OSError as e: # FileNotFound exception under py3 |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
289 if e.errno == 2: |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
290 pass |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
291 else: |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
292 raise |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
293 |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
294 print(ret) |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
295 self.assertTrue(ret == 0) |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
296 self.assertTrue(os.path.isfile(self.dirname + "/config.ini")) |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
297 self.assertTrue(os.path.isfile(self.dirname + "/schema.py")) |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
298 config=CoreConfig(self.dirname) |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
299 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
|
300 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
301 def testFind(self): |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
302 ''' 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
|
303 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
|
304 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
|
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 self.install_init() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
308 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
309 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
|
310 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
|
311 '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
|
312 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
|
313 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
314 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
|
315 print(out) |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
316 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
|
317 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
318 self.admin=AdminTool() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
319 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
|
320 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
|
321 '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
|
322 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
|
323 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
324 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
|
325 print(out) |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
326 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
|
327 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
328 self.admin=AdminTool() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
329 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
|
330 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
|
331 'assignedto=1'] |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
332 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
|
333 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
334 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
|
335 print(out) |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
336 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
|
337 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
338 # 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
|
339 self.admin=AdminTool() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
340 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
|
341 ''' 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
|
342 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
|
343 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
344 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
|
345 'assignedto=1,2'] |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
346 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
|
347 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
348 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
|
349 print(out) |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
350 # 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
|
351 # 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
|
352 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
|
353 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
354 # 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
|
355 self.admin=AdminTool() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
356 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
|
357 ''' 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
|
358 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
|
359 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
360 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
|
361 'assignedto=admin,anonymous'] |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
362 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
|
363 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
364 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
|
365 print(out) |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
366 # 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
|
367 # 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
|
368 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
|
369 |
|
6188
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
370 def testGenconfigUpdate(self): |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
371 ''' 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
|
372 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
|
373 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
|
374 ''' |
|
7182
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
375 import filecmp |
|
6188
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 self.admin=AdminTool() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
378 self.install_init() |
|
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'] |
|
6188
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
382 ret = self.admin.main() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
383 |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
384 out = out.getvalue().strip() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
385 print(out) |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
386 expected = "Not enough arguments supplied" |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
387 self.assertTrue(expected in out) |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
388 |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
389 # Reopen the db closed by previous call |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
390 self.admin=AdminTool() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
391 |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
392 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
|
393 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
|
394 self.dirname + "/config2.ini"] |
|
6188
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
395 ret = self.admin.main() |
|
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 out = out.getvalue().strip() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
398 print(out) |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
399 # FIXME get better successful test later. |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
400 expected = "" |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
401 self.assertTrue(expected in out) |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
402 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
|
403 # 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
|
404 # 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
|
405 # to be customized. |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
406 #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
|
407 # self.dirname + "/config.ini")) |
|
6188
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
408 |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
409 # Reopen the db closed by previous call |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
410 self.admin=AdminTool() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
411 |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
412 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
|
413 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
|
414 self.dirname + "/foo2.ini"] |
|
6188
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
415 ret = self.admin.main() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
416 |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
417 out = out.getvalue().strip() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
418 print(out) |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
419 # FIXME get better successful test later. |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
420 expected = "" |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
421 self.assertTrue(expected in out) |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
422 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
|
423 |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
424 # 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
|
425 # so filecmp passes. |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
426 normalize_file(self.dirname + "/foo2.ini", |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
427 [ '# Autogenerated at' ]) |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
428 normalize_file(self.dirname + "/config.ini", |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
429 [ '# Autogenerated at' ]) |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
430 |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
431 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
|
432 self.dirname + "/foo2.ini")) |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
433 |
|
7204
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
434 def testUpdateconfigPbkdf2(self): |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
435 ''' 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
|
436 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
|
437 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
|
438 ''' |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
439 import filecmp |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
440 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
441 self.admin=AdminTool() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
442 self.install_init() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
443 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
444 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
|
445 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
|
446 self.dirname + "/config2.ini"] |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
447 ret = self.admin.main() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
448 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
449 out = out.getvalue().strip() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
450 print(out) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
451 self.assertEqual(out, "") |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
452 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
|
453 # 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
|
454 # so filecmp passes. |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
455 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
|
456 [ '# Autogenerated at' ]) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
457 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
|
458 [ '# Autogenerated at' ]) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
459 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
460 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
|
461 self.dirname + "/config2.ini")) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
462 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
463 # 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
|
464 self.admin=AdminTool() |
|
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 ### 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
|
467 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
|
468 "= 2000000", "= 10000") |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
469 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
|
470 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
|
471 self.dirname + "/config2.ini"] |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
472 ret = self.admin.main() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
473 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
474 out = out.getvalue().strip() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
475 print(out) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
476 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
|
477 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
478 self.assertIn(expected, out) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
479 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
|
480 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
|
481 "^password_.*= 2000000$"), |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
482 "password_pbkdf2_default_rounds = 2000000") |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
483 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
484 # 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
|
485 self.admin=AdminTool() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
486 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
487 ### 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
|
488 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
|
489 "= 10000", "= 10001") |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
490 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
|
491 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
|
492 self.dirname + "/config2.ini"] |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
493 ret = self.admin.main() |
|
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 out = out.getvalue().strip() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
496 print(out) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
497 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
|
498 "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
|
499 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
500 self.assertIn(expected, out) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
501 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
|
502 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
|
503 "^password_.*= 10001$"), |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
504 "password_pbkdf2_default_rounds = 10001") |
|
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 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
507 # 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
|
508 self.admin=AdminTool() |
|
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 ### 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
|
511 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
|
512 "= 10001", "= 2000001") |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
513 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
|
514 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
|
515 self.dirname + "/config2.ini"] |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
516 ret = self.admin.main() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
517 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
518 out = out.getvalue().strip() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
519 print(out) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
520 expected = "" |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
521 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
522 self.assertEqual(expected, out) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
523 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
|
524 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
|
525 "^password_.*= 2000001$"), |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
526 "password_pbkdf2_default_rounds = 2000001") |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
527 |
|
6188
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
528 |
|
6186
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
529 def testCliParse(self): |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
530 ''' 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
|
531 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
|
532 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
|
533 ''' |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
534 self.admin=AdminTool() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
535 self.install_init() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
536 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
537 # 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
|
538 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
539 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
|
540 ''' 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
|
541 report error. |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
542 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
543 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
|
544 'assignedto=1'] |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
545 ret = self.admin.main() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
546 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
547 out = out.getvalue().strip() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
548 print(out) |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
549 expected="[ '1' ]" |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
550 self.assertTrue(expected, out) |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
551 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
552 # 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
|
553 self.admin=AdminTool() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
554 # test multiple matches |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
555 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
|
556 ''' 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
|
557 report error. |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
558 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
559 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
|
560 'assignedto'] |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
561 ret = self.admin.main() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
562 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
563 out = out.getvalue().strip() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
564 print(out) |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
565 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
|
566 self.assertEqual(expected, out) |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
567 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
568 # 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
|
569 self.admin=AdminTool() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
570 # 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
|
571 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
|
572 ''' 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
|
573 report error. |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
574 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
575 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
|
576 'assignedto'] |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
577 ret = self.admin.main() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
578 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
579 out = out.getvalue().strip() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
580 print(out) |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
581 expected=('Unknown command "xyzzy" ' |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
582 '("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
|
583 self.assertEqual(expected, out) |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
584 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
585 # 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
|
586 self.admin=AdminTool() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
587 # 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
|
588 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
|
589 ''' 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
|
590 report error. |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
591 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
592 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
|
593 'assignedto'] |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
594 ret = self.admin.main() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
595 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
596 out = out.getvalue().strip() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
597 print(out) |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
598 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
|
599 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
|
600 |
|
6177
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
601 def testFilter(self): |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
602 ''' 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
|
603 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
|
604 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
|
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 self.install_init() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
608 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
609 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
|
610 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
|
611 'title="foo bar"', 'assignedto=admin' ] |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
612 ret = self.admin.main() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
613 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
614 out = out.getvalue().strip() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
615 print(out) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
616 self.assertEqual(out, '1') |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
617 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
618 self.admin=AdminTool() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
619 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
|
620 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
|
621 'title="bar foo bar"', 'assignedto=anonymous' ] |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
622 ret = self.admin.main() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
623 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
624 out = out.getvalue().strip() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
625 print(out) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
626 self.assertEqual(out, '2') |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
627 |
|
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 - one results, one value, 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): |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
633 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
|
634 'username=admin'] |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
635 ret = self.admin.main() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
636 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
637 out = out.getvalue().strip() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
638 print(out) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
639 self.assertEqual(out, "['1']") |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
640 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
641 # Reopen the db closed by previous filter call |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
642 # test string - two results, two values, substring |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
643 self.admin=AdminTool() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
644 with captured_output() as (out, err): |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
645 ''' 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
|
646 so admin or anonymous |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
647 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
648 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
|
649 'username=a,n'] |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
650 ret = self.admin.main() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
651 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
652 out = out.getvalue().strip() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
653 print(out) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
654 # out can be "['2', '1']" or "['1', '2']" |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
655 # 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
|
656 self.assertEqual(sorted(eval(out)), ['1', '2']) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
657 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
658 # Reopen the db closed by previous filter call |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
659 # test string - one result, two values, substring |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
660 self.admin=AdminTool() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
661 with captured_output() as (out, err): |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
662 ''' 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
|
663 so anonymous |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
664 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
665 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
|
666 'username=a,y'] |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
667 ret = self.admin.main() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
668 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
669 out = out.getvalue().strip() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
670 print(out) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
671 self.assertEqual(out, "['2']") |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
672 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
673 # Reopen the db closed by previous filter call |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
674 # test string - no results |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
675 self.admin=AdminTool() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
676 with captured_output() as (out, err): |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
677 ''' will return empty set as admin!=anonymous |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
678 ''' |
|
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', 'user', |
|
6177
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
680 'username=admin,anonymous'] |
|
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(out, "[]") |
|
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 ids |
|
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): |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
691 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
|
692 'assignedto=1,2'] |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
693 ret = self.admin.main() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
694 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
695 out = out.getvalue().strip() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
696 print(out) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
697 self.assertEqual(sorted(eval(out)), ['1', '2']) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
698 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
699 # Reopen the db closed by previous filter call |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
700 # test link using names |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
701 self.admin=AdminTool() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
702 with captured_output() as (out, err): |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
703 ''' will return empty set as admin!=anonymous |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
704 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
705 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
|
706 'assignedto=admin,anonymous'] |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
707 ret = self.admin.main() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
708 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
709 out = out.getvalue().strip() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
710 print(out) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
711 self.assertEqual(sorted(eval(out)), ['1', '2']) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
712 |
|
6250
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
713 # 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
|
714 # |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
715 # case: transitive property valid match |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
716 self.admin=AdminTool() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
717 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
|
718 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
|
719 'assignedto.roles=Anonymous'] |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
720 ret = self.admin.main() |
|
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 out = out.getvalue().strip() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
723 print(out) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
724 self.assertEqual(out, "['2']") |
|
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 # 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
|
727 # self.admin=AdminTool() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
728 # case: transitive propery invalid prop |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
729 self.admin=AdminTool() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
730 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
|
731 ''' 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
|
732 report error. |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
733 ''' |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
734 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
|
735 'assignedto.badprop=Admin'] |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
736 ret = self.admin.main() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
737 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
738 out = out.getvalue().strip() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
739 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
|
740 print(out[0:len(expected)]) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
741 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
|
742 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
743 # 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
|
744 # |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
745 # case: transitive property invalid match |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
746 self.admin=AdminTool() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
747 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
|
748 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
|
749 'filter', 'issue', |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
750 'assignedto.username=NoNAme'] |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
751 ret = self.admin.main() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
752 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
753 out = out.getvalue().strip() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
754 print("me: " + out) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
755 print(err.getvalue().strip()) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
756 self.assertEqual(out, "[]") |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
757 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
758 # 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
|
759 # |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
760 # case: transitive property invalid match |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
761 self.admin=AdminTool() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
762 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
|
763 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
|
764 'filter', 'issue', |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
765 'assignedto.username=NoNAme'] |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
766 ret = self.admin.main() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
767 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
768 out = out.getvalue().strip() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
769 print("me: " + out) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
770 print(err.getvalue().strip()) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
771 self.assertEqual(out, "") |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
772 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
773 # 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
|
774 # |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
775 # case: transitive property invalid match |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
776 self.admin=AdminTool() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
777 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
|
778 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
|
779 'filter', 'issue', |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
780 'assignedto.username=A'] |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
781 ret = self.admin.main() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
782 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
783 out = out.getvalue().strip() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
784 print("me: " + out) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
785 print(err.getvalue().strip()) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
786 self.assertEqual(out, "1,2") |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
787 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
788 # 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
|
789 # |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
790 # case: transitive property invalid match |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
791 self.admin=AdminTool() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
792 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
|
793 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
|
794 'filter', 'issue', |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
795 'assignedto.username=A'] |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
796 ret = self.admin.main() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
797 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
798 out = out.getvalue().strip() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
799 print("me: " + out) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
800 print(err.getvalue().strip()) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
801 self.assertEqual(out, "1 2") |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
802 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
803 # 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
|
804 # |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
805 # case: transitive property invalid match |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
806 self.admin=AdminTool() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
807 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
|
808 sys.argv=['main', '-i', self.dirname, '-S', ':', |
|
6251
b303db7f384f
Test designator code path
John Rouillard <rouilj@ieee.org>
parents:
6250
diff
changeset
|
809 '-d', 'filter', 'issue', |
|
6250
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
810 'assignedto.username=A'] |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
811 ret = self.admin.main() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
812 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
813 out = out.getvalue().strip() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
814 print("me: " + out) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
815 print(err.getvalue().strip()) |
|
6251
b303db7f384f
Test designator code path
John Rouillard <rouilj@ieee.org>
parents:
6250
diff
changeset
|
816 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
|
817 |
|
7254
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
818 def testPragma_reopen_tracker(self): |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
819 """test that _reopen_tracker works. |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
820 """ |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
821 if self.backend not in ['anydbm']: |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
822 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
|
823 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
824 orig_input = AdminTool.my_input |
|
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 # 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
|
827 # and to get "Reopening tracker" verbose log output |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
828 inputs = iter(["pragma verbose=true", "pragma list", "quit"]) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
829 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
830 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
831 self.install_init() |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
832 self.admin=AdminTool() |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
833 sys.argv=['main', '-i', self.dirname] |
|
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 with captured_output() as (out, err): |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
836 ret = self.admin.main() |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
837 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
838 out = out.getvalue().strip().split('\n') |
|
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 print(ret) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
841 self.assertTrue(ret == 0) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
842 expected = ' _reopen_tracker=False' |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
843 self.assertIn(expected, out) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
844 self.assertIn('descriptions...', out[-1]) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
845 self.assertNotIn('Reopening tracker', out) |
|
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 # ----- |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
848 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
|
849 "pragma list", "quit"]) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
850 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
851 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
852 self.install_init() |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
853 self.admin=AdminTool() |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
854 sys.argv=['main', '-i', self.dirname] |
|
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 with captured_output() as (out, err): |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
857 ret = self.admin.main() |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
858 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
859 out = out.getvalue().strip().split('\n') |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
860 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
861 print(ret) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
862 self.assertTrue(ret == 0) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
863 self.assertEqual('Reopening tracker', out[2]) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
864 expected = ' _reopen_tracker=True' |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
865 self.assertIn(expected, out) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
866 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
867 # ----- |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
868 AdminTool.my_input = orig_input |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
869 |
|
7252
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
870 def testPragma(self): |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
871 """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
|
872 commands. |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
873 """ |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
874 if self.backend not in ['anydbm']: |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
875 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
|
876 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
877 orig_input = AdminTool.my_input |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
878 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
879 for i in ["oN", "1", "yeS", "True"]: |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
880 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
|
881 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
882 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
883 self.install_init() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
884 self.admin=AdminTool() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
885 sys.argv=['main', '-i', self.dirname] |
|
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 with captured_output() as (out, err): |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
888 ret = self.admin.main() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
889 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
890 out = out.getvalue().strip().split('\n') |
|
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 print(ret) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
893 self.assertTrue(ret == 0) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
894 expected = ' verbose=True' |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
895 self.assertIn(expected, out) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
896 self.assertIn('descriptions...', out[-1]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
897 |
|
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 for i in ["oFf", "0", "NO", "FalSe"]: |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
900 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
|
901 "pragma list", "quit"]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
902 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
903 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
904 self.install_init() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
905 self.admin=AdminTool() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
906 sys.argv=['main', '-i', self.dirname] |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
907 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
908 with captured_output() as (out, err): |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
909 ret = self.admin.main() |
|
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 out = out.getvalue().strip().split('\n') |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
912 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
913 print(ret) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
914 self.assertTrue(ret == 0) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
915 expected = ' verbose=False' |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
916 self.assertIn(expected, out) |
|
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 # ----- test syntax errors |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
919 inputs = iter(["pragma", "pragma arg", |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
920 "pragma foo=3","quit"]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
921 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
922 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
923 self.install_init() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
924 self.admin=AdminTool() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
925 sys.argv=['main', '-i', self.dirname] |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
926 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
927 with captured_output() as (out, err): |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
928 ret = self.admin.main() |
|
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 out = out.getvalue().strip().split('\n') |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
931 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
932 print(ret) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
933 self.assertTrue(ret == 0) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
934 expected = 'Error: Not enough arguments supplied' |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
935 self.assertIn(expected, out) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
936 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
|
937 self.assertIn(expected, out) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
938 expected = 'Error: Unknown setting foo.' |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
939 self.assertIn(expected, out) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
940 |
|
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 inputs = iter(["pragma verbose=foo", "quit"]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
943 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
944 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
945 self.install_init() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
946 self.admin=AdminTool() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
947 sys.argv=['main', '-i', self.dirname] |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
948 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
949 with captured_output() as (out, err): |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
950 ret = self.admin.main() |
|
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 out = out.getvalue().strip().split('\n') |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
953 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
954 print(ret) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
955 self.assertTrue(ret == 0) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
956 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
|
957 self.assertIn(expected, out) |
|
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 # ----- |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
960 inputs = iter(["pragma verbose=on", "pragma _inttest=5", |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
961 "pragma list", "quit"]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
962 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
963 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
964 self.install_init() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
965 self.admin=AdminTool() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
966 sys.argv=['main', '-i', self.dirname] |
|
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 with captured_output() as (out, err): |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
969 ret = self.admin.main() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
970 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
971 out = out.getvalue().strip().split('\n') |
|
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 print(ret) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
974 self.assertTrue(ret == 0) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
975 expected = ' _inttest=5' |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
976 self.assertIn(expected, out) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
977 self.assertIn('descriptions...', out[-1]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
978 |
|
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 # ----- |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
981 inputs = iter(["pragma verbose=on", "pragma _inttest=fred", |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
982 "pragma list", "quit"]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
983 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
984 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
985 self.install_init() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
986 self.admin=AdminTool() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
987 sys.argv=['main', '-i', self.dirname] |
|
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 with captured_output() as (out, err): |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
990 ret = self.admin.main() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
991 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
992 out = out.getvalue().strip().split('\n') |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
993 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
994 print(ret) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
995 self.assertTrue(ret == 0) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
996 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
|
997 self.assertIn(expected, out) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
998 self.assertIn('descriptions...', out[-1]) |
|
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 # ----- |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1001 inputs = iter(["pragma indexer_backend=whoosh", "pragma list", |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1002 "quit"]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1003 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1004 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1005 self.install_init() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1006 self.admin=AdminTool() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1007 sys.argv=['main', '-i', self.dirname] |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1008 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1009 with captured_output() as (out, err): |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1010 ret = self.admin.main() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1011 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1012 out = out.getvalue().strip().split('\n') |
|
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 print(ret) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1015 expected = ' indexer_backend=whoosh' |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1016 self.assertIn(expected, out) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1017 |
|
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 inputs = iter(["pragma _floattest=4.5", "quit"]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1020 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1021 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1022 self.install_init() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1023 self.admin=AdminTool() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1024 sys.argv=['main', '-i', self.dirname] |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1025 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1026 with captured_output() as (out, err): |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1027 ret = self.admin.main() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1028 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1029 out = out.getvalue().strip().split('\n') |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1030 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1031 print(ret) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1032 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
|
1033 self.assertIn(expected, out) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1034 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1035 # ----- |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1036 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
|
1037 |
| 6199 | 1038 def disabletestHelpInitopts(self): |
| 1039 | |
| 1040 ''' Note the tests will fail if you run this under pdb. | |
| 1041 the context managers capture the pdb prompts and this screws | |
| 1042 up the stdout strings with (pdb) prefixed to the line. | |
| 1043 ''' | |
| 1044 self.install_init() | |
| 1045 self.admin=AdminTool() | |
| 1046 | |
| 1047 with captured_output() as (out, err): | |
| 1048 sys.argv=['main', '-i', self.dirname, 'help', 'initopts'] | |
| 1049 ret = self.admin.main() | |
| 1050 | |
| 1051 out = out.getvalue().strip() | |
| 1052 expected = [ | |
| 1053 'Templates: minimal, jinja2, classic, responsive, devel', | |
| 1054 'Back ends: anydbm, sqlite' | |
| 1055 ] | |
| 1056 print(out) | |
| 1057 self.assertTrue(expected[0] in out) | |
| 1058 self.assertTrue("Back ends:" in out) | |
| 1059 | |
|
6393
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1060 def testSecurity(self): |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1061 ''' 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
|
1062 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
|
1063 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
|
1064 ''' |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1065 self.install_init() |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1066 self.admin=AdminTool() |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1067 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1068 with captured_output() as (out, err): |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1069 sys.argv=['main', '-i', self.dirname, 'security' ] |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1070 ret = self.admin.main() |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1071 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1072 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
|
1073 New Email users get the Role "User" |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1074 Role "admin": |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1075 User may create everything (Create) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1076 User may edit everything (Edit) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1077 User may restore everything (Restore) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1078 User may retire everything (Retire) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1079 User may view everything (View) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1080 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
|
1081 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
|
1082 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
|
1083 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
|
1084 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
|
1085 Role "anonymous": |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1086 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
|
1087 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
|
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 access file (View for "file" only) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1090 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
|
1091 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
|
1092 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
|
1093 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
|
1094 (Search for "user" only) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1095 Role "user": |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1096 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
|
1097 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
|
1098 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
|
1099 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
|
1100 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
|
1101 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
|
1102 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
|
1103 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
|
1104 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
|
1105 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
|
1106 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
|
1107 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
|
1108 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
|
1109 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
|
1110 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
|
1111 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
|
1112 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
|
1113 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
|
1114 (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
|
1115 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
|
1116 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
|
1117 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
|
1118 (Search for "query" only) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1119 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
|
1120 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
|
1121 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
|
1122 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
|
1123 """ |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1124 print(out.getvalue()) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1125 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1126 self.assertEqual(result, out.getvalue()) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1127 self.assertEqual(ret, 0) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1128 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1129 def testSecurityInvalidAttribute(self): |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1130 ''' Test with an invalid attribute. |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1131 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
|
1132 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
|
1133 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
|
1134 ''' |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1135 self.maxDiff = None # we want full diff |
|
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.install_init() |
|
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 # edit in an invalid attribute/property |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1140 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
|
1141 d = f.readlines() |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1142 f.seek(0) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1143 for i in d: |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1144 if "organisation" in i: |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1145 i = i.replace("'id', 'organisation'","'id', 'organization'") |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1146 f.write(i) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1147 f.truncate() |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1148 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1149 self.admin=AdminTool() |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1150 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1151 with captured_output() as (out, err): |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1152 sys.argv=['main', '-i', self.dirname, 'security' ] |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1153 ret = self.admin.main() |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1154 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1155 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
|
1156 New Email users get the Role "User" |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1157 Role "admin": |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1158 User may create everything (Create) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1159 User may edit everything (Edit) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1160 User may restore everything (Restore) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1161 User may retire everything (Retire) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1162 User may view everything (View) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1163 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
|
1164 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
|
1165 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
|
1166 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
|
1167 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
|
1168 Role "anonymous": |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1169 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
|
1170 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
|
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 access file (View for "file" only) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1173 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
|
1174 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
|
1175 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
|
1176 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
|
1177 (Search for "user" only) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1178 Role "user": |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1179 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
|
1180 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
|
1181 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
|
1182 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
|
1183 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
|
1184 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
|
1185 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
|
1186 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
|
1187 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
|
1188 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
|
1189 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
|
1190 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
|
1191 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
|
1192 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
|
1193 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
|
1194 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
|
1195 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
|
1196 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
|
1197 (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
|
1198 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1199 **Invalid properties for user: ['organization'] |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1200 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1201 """ |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1202 print(out.getvalue()) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1203 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1204 self.assertEqual(result, out.getvalue()) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1205 self.assertEqual(ret, 1) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1206 |
|
6181
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1207 def testSet(self): |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1208 ''' 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
|
1209 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
|
1210 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
|
1211 ''' |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1212 self.install_init() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1213 self.admin=AdminTool() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1214 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1215 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
|
1216 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
|
1217 '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
|
1218 ret = self.admin.main() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1219 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1220 out = out.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1221 print(out) |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1222 self.assertEqual(out, '1') |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1223 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1224 self.admin=AdminTool() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1225 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
|
1226 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
|
1227 '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
|
1228 ret = self.admin.main() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1229 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1230 out = out.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1231 print(out) |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1232 self.assertEqual(out, '2') |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1233 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1234 self.admin=AdminTool() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1235 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
|
1236 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
|
1237 ret = self.admin.main() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1238 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1239 out = out.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1240 err = err.getvalue().strip() |
|
6332
6a6b4651be1f
Use server-side cursor for postgres in some cases
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6251
diff
changeset
|
1241 self.assertEqual(out, '') |
|
6a6b4651be1f
Use server-side cursor for postgres in some cases
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6251
diff
changeset
|
1242 self.assertEqual(err, '') |
|
6181
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1243 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1244 self.admin=AdminTool() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1245 with captured_output() as (out, err): |
| 6199 | 1246 sys.argv=['main', '-i', self.dirname, 'set', 'issue2', |
| 1247 'tile="new title"'] | |
|
6181
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1248 ret = self.admin.main() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1249 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1250 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
|
1251 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1252 out = out.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1253 err = err.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1254 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
|
1255 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
|
1256 |
| 6199 | 1257 self.admin=AdminTool() |
| 1258 with captured_output() as (out, err): | |
| 1259 sys.argv=['main', '-i', self.dirname, 'set', 'issue2'] | |
| 1260 ret = self.admin.main() | |
| 1261 | |
| 1262 expected_err = "Error: Not enough arguments supplied" | |
| 1263 | |
| 1264 out = out.getvalue().strip() | |
| 1265 err = err.getvalue().strip() | |
| 1266 self.assertEqual(out.index(expected_err), 0) | |
| 1267 self.assertEqual(len(err), 0) | |
| 1268 | |
| 1269 | |
| 1270 self.admin=AdminTool() | |
| 1271 with captured_output() as (out, err): | |
| 1272 sys.argv=['main', '-i', self.dirname, 'set', | |
| 1273 'issue2,issue1,issue', "status=1" ] | |
| 1274 ret = self.admin.main() | |
| 1275 | |
| 1276 expected_err = 'Error: "issue" not a node designator' | |
| 1277 | |
| 1278 out = out.getvalue().strip() | |
| 1279 err = err.getvalue().strip() | |
| 1280 self.assertEqual(out.index(expected_err), 0) | |
| 1281 self.assertEqual(len(err), 0) | |
| 1282 | |
| 1283 self.admin=AdminTool() | |
| 1284 with captured_output() as (out, err): | |
| 1285 sys.argv=['main', '-i', self.dirname, 'set', | |
| 1286 'issue2,issue1,user2', "status=1" ] | |
| 1287 ret = self.admin.main() | |
| 1288 | |
| 1289 expected_err = "Error: 'status' is not a property of user" | |
| 1290 | |
| 1291 out = out.getvalue().strip() | |
| 1292 err = err.getvalue().strip() | |
| 1293 print(out) | |
| 1294 print(expected_err) | |
| 1295 print(err) | |
| 1296 self.assertEqual(out.index(expected_err), 0) | |
| 1297 self.assertEqual(len(err), 0) | |
| 1298 | |
| 1299 self.admin=AdminTool() | |
| 1300 with captured_output() as (out, err): | |
| 1301 sys.argv=['main', '-i', self.dirname, 'set', | |
| 1302 'issue2,issue1,issue1000', "status=1" ] | |
| 1303 ret = self.admin.main() | |
| 1304 | |
| 1305 expected_err = 'Error: no such issue 1000' | |
| 1306 | |
| 1307 out = out.getvalue().strip() | |
| 1308 err = err.getvalue().strip() | |
| 1309 self.assertEqual(out.index(expected_err), 0) | |
| 1310 self.assertEqual(len(err), 0) | |
| 1311 | |
| 1312 def testSetOnClass(self): | |
| 1313 ''' Note the tests will fail if you run this under pdb. | |
| 1314 the context managers capture the pdb prompts and this screws | |
| 1315 up the stdout strings with (pdb) prefixed to the line. | |
| 1316 ''' | |
| 1317 self.install_init() | |
| 1318 | |
| 1319 self.admin=AdminTool() | |
| 1320 with captured_output() as (out, err): | |
| 1321 sys.argv=['main', '-i', self.dirname, 'create', 'issue', | |
| 1322 'title="foo bar"', 'assignedto=admin' ] | |
| 1323 ret = self.admin.main() | |
| 1324 | |
| 1325 out = out.getvalue().strip() | |
| 1326 print(out) | |
| 1327 self.assertEqual(out, '1') | |
| 1328 | |
| 1329 self.admin=AdminTool() | |
| 1330 with captured_output() as (out, err): | |
| 1331 sys.argv=['main', '-i', self.dirname, 'create', 'issue', | |
| 1332 'title="bar foo bar"', 'assignedto=anonymous' ] | |
| 1333 ret = self.admin.main() | |
| 1334 | |
| 1335 out = out.getvalue().strip() | |
| 1336 print(out) | |
| 1337 self.assertEqual(out, '2') | |
| 1338 | |
| 1339 # Run this test in a separate test. | |
| 1340 # It can cause a database timeout/resource | |
| 1341 # unavailable error for anydbm when run with other tests. | |
| 1342 # Not sure why. | |
| 1343 # Set assignedto=2 for all issues | |
| 1344 ## verify that issue 1 and 2 are assigned to user1 and user2 | |
| 1345 self.admin=AdminTool() | |
| 1346 with captured_output() as (out, err): | |
| 1347 sys.argv=['main', '-i', self.dirname, 'table', 'issue', | |
| 1348 'assignedto'] | |
| 1349 ret = self.admin.main() | |
| 1350 | |
| 1351 expected = "Assignedto\n1 \n2" | |
| 1352 out = out.getvalue().strip() | |
| 1353 err = err.getvalue().strip() | |
| 1354 self.assertEqual(out, expected) | |
| 1355 self.assertEqual(len(err), 0) | |
| 1356 self.admin=AdminTool() | |
| 1357 # do the set | |
| 1358 with captured_output() as (out, err): | |
| 1359 sys.argv=['main', '-i', self.dirname, 'set', 'issue', | |
| 1360 'assignedto=2'] | |
| 1361 ret = self.admin.main() | |
| 1362 | |
| 1363 expected_err = "" | |
| 1364 | |
| 1365 out = out.getvalue().strip() | |
| 1366 err = err.getvalue().strip() | |
|
6332
6a6b4651be1f
Use server-side cursor for postgres in some cases
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6251
diff
changeset
|
1367 self.assertEqual(out, '') |
|
6a6b4651be1f
Use server-side cursor for postgres in some cases
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6251
diff
changeset
|
1368 self.assertEqual(err, '') |
| 6199 | 1369 |
| 1370 ## verify that issue 1 and 2 are assigned to user2 and user2 | |
| 1371 self.admin=AdminTool() | |
| 1372 with captured_output() as (out, err): | |
| 1373 sys.argv=['main', '-i', self.dirname, 'table', 'issue', | |
| 1374 'assignedto'] | |
| 1375 ret = self.admin.main() | |
| 1376 | |
| 1377 expected = "Assignedto\n2 \n2" | |
| 1378 out = out.getvalue().strip() | |
| 1379 err = err.getvalue().strip() | |
| 1380 self.assertEqual(out, expected) | |
| 1381 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
|
1382 |
|
6176
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
1383 def testSpecification(self): |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
1384 ''' 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
|
1385 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
|
1386 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
|
1387 ''' |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
1388 self.install_init() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
1389 self.admin=AdminTool() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
1390 |
|
6178
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1391 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
|
1392 'alternate_addresses: <roundup.hyperdb.String>', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1393 'realname: <roundup.hyperdb.String>', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1394 'roles: <roundup.hyperdb.String>', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1395 'organisation: <roundup.hyperdb.String>', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1396 'queries: <roundup.hyperdb.Multilink to "query">', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1397 'phone: <roundup.hyperdb.String>', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1398 'address: <roundup.hyperdb.String>', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1399 'timezone: <roundup.hyperdb.String>', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1400 'password: <roundup.hyperdb.Password>', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1401 ] |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1402 |
|
6176
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
1403 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
|
1404 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
|
1405 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
|
1406 |
|
6178
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1407 outlist = out.getvalue().strip().split("\n") |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1408 print(outlist) |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1409 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
|
1410 |
|
6430
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
1411 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
|
1412 ''' 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
|
1413 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
|
1414 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
|
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 # 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
|
1417 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
|
1418 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
|
1419 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
|
1420 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
|
1421 '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
|
1422 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
|
1423 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
1424 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
|
1425 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
|
1426 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
|
1427 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
1428 # 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
|
1429 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
|
1430 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
|
1431 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
|
1432 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
|
1433 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
|
1434 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
|
1435 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
|
1436 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
1437 # 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
|
1438 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
|
1439 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
|
1440 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
|
1441 '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
|
1442 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
|
1443 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
1444 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
|
1445 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
|
1446 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
|
1447 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
1448 # 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
|
1449 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
|
1450 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
|
1451 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
|
1452 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
|
1453 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
|
1454 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
|
1455 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
|
1456 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
1457 # 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
|
1458 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
|
1459 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
|
1460 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
|
1461 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
|
1462 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
|
1463 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
|
1464 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
|
1465 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
|
1466 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
1467 # 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
|
1468 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
|
1469 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
|
1470 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
|
1471 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
|
1472 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
|
1473 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
|
1474 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
|
1475 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
1476 # 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
|
1477 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
|
1478 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
|
1479 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
|
1480 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
|
1481 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
|
1482 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
|
1483 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
|
1484 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
1485 # 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
|
1486 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
|
1487 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
|
1488 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
|
1489 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
|
1490 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
|
1491 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
|
1492 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
|
1493 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
|
1494 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
1495 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
1496 |
| 6199 | 1497 def testTable(self): |
| 1498 ''' Note the tests will fail if you run this under pdb. | |
| 1499 the context managers capture the pdb prompts and this screws | |
| 1500 up the stdout strings with (pdb) prefixed to the line. | |
| 1501 ''' | |
| 1502 self.install_init() | |
| 1503 self.admin=AdminTool() | |
| 1504 | |
| 1505 with captured_output() as (out, err): | |
| 1506 sys.argv=['main', '-i', self.dirname, 'table' ] | |
| 1507 ret = self.admin.main() | |
| 1508 | |
| 1509 expected = 'Error: Not enough arguments supplied' | |
| 1510 | |
| 1511 out = out.getvalue().strip() | |
| 1512 print(out) | |
| 1513 print(expected) | |
| 1514 self.assertTrue(expected in out) | |
| 1515 #### | |
| 1516 | |
| 1517 self.admin=AdminTool() | |
| 1518 | |
| 1519 with captured_output() as (out, err): | |
| 1520 sys.argv=['main', '-i', self.dirname, 'table', | |
| 1521 'id,realname,username' ] | |
| 1522 ret = self.admin.main() | |
| 1523 | |
| 1524 expected = 'Error: no such class "id,realname,username"' | |
| 1525 | |
| 1526 out = out.getvalue().strip() | |
| 1527 print(out) | |
| 1528 print(expected) | |
| 1529 self.assertTrue(expected in out) | |
| 1530 | |
| 1531 #### | |
| 1532 self.admin=AdminTool() | |
| 1533 | |
| 1534 with captured_output() as (out, err): | |
| 1535 sys.argv=['main', '-i', self.dirname, 'table', 'user', | |
| 1536 'id,realname,username:4:3' ] | |
| 1537 ret = self.admin.main() | |
| 1538 expected = 'Error: "username:4:3" not name:width' | |
| 1539 | |
| 1540 out = out.getvalue().strip() | |
| 1541 print(out) | |
| 1542 print(expected) | |
| 1543 self.assertTrue(expected in out) | |
| 1544 | |
| 1545 #### | |
| 1546 self.admin=AdminTool() | |
| 1547 | |
| 1548 with captured_output() as (out, err): | |
| 1549 sys.argv=['main', '-i', self.dirname, 'table', 'user', | |
| 1550 'id,realname,title:4' ] | |
| 1551 ret = self.admin.main() | |
| 1552 expected = 'Error: user has no property "title"' | |
| 1553 | |
| 1554 out = out.getvalue().strip() | |
| 1555 print(out) | |
| 1556 print(expected) | |
| 1557 self.assertTrue(expected in out) | |
| 1558 | |
| 1559 #### | |
| 1560 self.admin=AdminTool() | |
| 1561 | |
| 1562 with captured_output() as (out, err): | |
| 1563 sys.argv=['main', '-i', self.dirname, 'table', 'user', | |
| 1564 'id,realname,username:' ] | |
| 1565 ret = self.admin.main() | |
| 1566 | |
| 1567 # note whitespace matters. trailing spaces on lines 1 and 2 | |
| 1568 expected = """Id Realname Username | |
| 1569 1 None admin | |
| 1570 2 None anonymou""" | |
| 1571 | |
| 1572 out = out.getvalue().strip() | |
| 1573 print(out) | |
| 1574 print(expected) | |
| 1575 self.assertEqual(out, expected) | |
| 1576 | |
| 1577 #### | |
| 1578 self.admin=AdminTool() | |
| 1579 | |
| 1580 with captured_output() as (out, err): | |
| 1581 sys.argv=['main', '-i', self.dirname, 'table', 'user', | |
| 1582 'id,realname,username' ] | |
| 1583 ret = self.admin.main() | |
| 1584 | |
| 1585 # note whitespace matters. trailing spaces on lines 1 and 2 | |
| 1586 expected = """Id Realname Username | |
| 1587 1 None admin | |
| 1588 2 None anonymous""" | |
| 1589 | |
| 1590 out = out.getvalue().strip() | |
| 1591 print(out) | |
| 1592 print(expected) | |
| 1593 self.assertEqual(out, expected) | |
| 1594 | |
| 1595 #### | |
| 1596 self.admin=AdminTool() | |
| 1597 | |
| 1598 with captured_output() as (out, err): | |
| 1599 sys.argv=['main', '-i', self.dirname, 'table', 'user', | |
| 1600 'id:4,realname:2,username:3' ] | |
| 1601 ret = self.admin.main() | |
| 1602 | |
| 1603 # note whitespace matters. trailing spaces on lines 1 and 2 | |
| 1604 expected = """Id Realname Username | |
| 1605 1 No adm | |
| 1606 2 No ano""" | |
| 1607 | |
| 1608 out = out.getvalue().strip() | |
| 1609 print(out) | |
| 1610 print(expected) | |
| 1611 self.assertEqual(out, expected) | |
| 1612 | |
|
6957
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
1613 def testTemplates(self): |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
1614 |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
1615 self.install_init() |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
1616 self.admin=AdminTool() |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
1617 |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
1618 with captured_output() as (out, err): |
|
6958
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
1619 # 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
|
1620 # 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
|
1621 sys.argv=['main', '-i', "zZzZ", 'templates' ] |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
1622 ret = self.admin.main() |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
1623 |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
1624 out = out.getvalue().strip() |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
1625 |
|
6958
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
1626 # 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
|
1627 for tracker in ['Name: classic\nPath:', |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
1628 'Name: devel\nPath:', |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
1629 'Name: jinja2\nPath:', |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
1630 'Name: minimal\nPath:', |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
1631 'Name: responsive\nPath:']: |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
1632 self.assertIn(tracker, out) |
|
5713
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
1633 |
|
6958
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
1634 with captured_output() as (out, err): |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
1635 # 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
|
1636 # directory to cause error if that changes |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
1637 sys.argv=['main', '-i', "zZzZ", 'templates', 'trace_search' ] |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
1638 ret = self.admin.main() |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
1639 |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
1640 out = out.getvalue().strip() |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
1641 |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
1642 expected = "/*\n" |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
1643 self.assertIn(expected, out) |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
1644 |
|
5713
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
1645 class anydbmAdminTest(AdminTest, unittest.TestCase): |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
1646 backend = 'anydbm' |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
1647 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
1648 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
1649 @skip_mysql |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
1650 class mysqlAdminTest(AdminTest, unittest.TestCase): |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
1651 backend = 'mysql' |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
1652 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
1653 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
1654 class sqliteAdminTest(AdminTest, unittest.TestCase): |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
1655 backend = 'sqlite' |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
1656 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
1657 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
1658 @skip_postgresql |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
1659 class postgresqlAdminTest(AdminTest, unittest.TestCase): |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
1660 backend = 'postgresql' |
