Mercurial > p > roundup > code
annotate test/test_admin.py @ 8237:57325fea9982
issue2551116 - Replace xmlrpclib (xmlrpc.client) with defusedxml.
defusedxml will be used to moneypatch the problematic client and
server modules.
Test added using an xml bomb.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 29 Dec 2024 19:11:01 -0500 |
| parents | c12377fb4144 |
| children | b4ad03927711 |
| 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 |
|
7582
978285986b2c
fix: issue2551193 - Fix roundup for removal of cgi and cgitb ...
John Rouillard <rouilj@ieee.org>
parents:
7549
diff
changeset
|
9 import unittest, os, shutil, errno, sys, difflib, re |
|
5713
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 |
|
7585
227aca44fea5
test: fix failure under cygwin python caused by line endings
John Rouillard <rouilj@ieee.org>
parents:
7582
diff
changeset
|
65 try: |
|
227aca44fea5
test: fix failure under cygwin python caused by line endings
John Rouillard <rouilj@ieee.org>
parents:
7582
diff
changeset
|
66 # handle text files with \r\n line endings |
|
7586
859c57bc8d91
test: limit search for \r to first 100 bytes.
John Rouillard <rouilj@ieee.org>
parents:
7585
diff
changeset
|
67 contents.index("\r", 0, 100) |
|
7585
227aca44fea5
test: fix failure under cygwin python caused by line endings
John Rouillard <rouilj@ieee.org>
parents:
7582
diff
changeset
|
68 contents = contents.replace("\r\n", "\n") |
|
227aca44fea5
test: fix failure under cygwin python caused by line endings
John Rouillard <rouilj@ieee.org>
parents:
7582
diff
changeset
|
69 except ValueError: |
|
227aca44fea5
test: fix failure under cygwin python caused by line endings
John Rouillard <rouilj@ieee.org>
parents:
7582
diff
changeset
|
70 pass |
|
227aca44fea5
test: fix failure under cygwin python caused by line endings
John Rouillard <rouilj@ieee.org>
parents:
7582
diff
changeset
|
71 |
|
7204
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
72 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
|
73 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
74 if not m: return False |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
75 |
|
7205
1a3d4703c7d6
Fix for python2. m[0] -> m.group(0)
John Rouillard <rouilj@ieee.org>
parents:
7204
diff
changeset
|
76 return m.group(0) |
|
7204
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
77 |
|
5713
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
78 class AdminTest(object): |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
79 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
80 backend = None |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
81 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
82 def setUp(self): |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
83 self.dirname = '_test_admin' |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
84 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
85 def tearDown(self): |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
86 try: |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
87 shutil.rmtree(self.dirname) |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
88 except OSError as error: |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
89 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
|
90 |
|
6176
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
91 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
|
92 settings="mail_domain=example.com," + |
|
6177
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
93 "mail_host=localhost," + |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
94 "tracker_web=http://test/," + |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
95 "rdbms_name=rounduptest," + |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
96 "rdbms_user=rounduptest," + |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
97 "rdbms_password=rounduptest," + |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
98 "rdbms_template=template0" |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
99 ): |
|
6176
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
100 ''' 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
|
101 ''' |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
102 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
103 admin=AdminTool() |
|
6178
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
104 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
|
105 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
106 # 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
|
107 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
|
108 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
|
109 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
|
110 ret = admin.main() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
111 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
|
112 |
|
6178
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
113 # nuke any existing database (mysql/postgreql) |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
114 # 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
|
115 #tracker = instance.open(self.dirname) |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
116 #if tracker.exists(): |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
117 # tracker.nuke() |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
118 |
|
6176
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
119 # 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
|
120 # 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
|
121 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
|
122 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
|
123 ret = admin.main() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
124 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
|
125 |
|
6178
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
126 |
|
7182
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
127 def testBasicInteractive(self): |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
128 # 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
|
129 inputs = iter(["'quit", "quit"]) |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
130 |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
131 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
|
132 |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
133 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
|
134 |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
135 self.install_init() |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
136 self.admin=AdminTool() |
|
7803
2746337ded4c
fix: disable history file changes when testing
John Rouillard <rouilj@ieee.org>
parents:
7802
diff
changeset
|
137 self.admin.settings['history_features'] = 2 |
|
7802
7c0a8088b053
feat: add support for controlling readline history features
John Rouillard <rouilj@ieee.org>
parents:
7752
diff
changeset
|
138 # set history_features to disable loading/saving history |
|
7c0a8088b053
feat: add support for controlling readline history features
John Rouillard <rouilj@ieee.org>
parents:
7752
diff
changeset
|
139 # and loading rc file. Otherwise file gets large and |
|
7c0a8088b053
feat: add support for controlling readline history features
John Rouillard <rouilj@ieee.org>
parents:
7752
diff
changeset
|
140 # breaks testing or overwrites the users history file. |
|
7803
2746337ded4c
fix: disable history file changes when testing
John Rouillard <rouilj@ieee.org>
parents:
7802
diff
changeset
|
141 sys.argv=['main', '-i', self.dirname] |
|
7182
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
142 |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
143 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
|
144 ret = self.admin.main() |
|
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 out = out.getvalue().strip() |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
147 |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
148 print(ret) |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
149 self.assertTrue(ret == 0) |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
150 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
|
151 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
|
152 |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
153 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
|
154 |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
155 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
|
156 |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
157 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
|
158 ret = self.admin.main() |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
159 |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
160 out = out.getvalue().strip() |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
161 |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
162 print(ret) |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
163 self.assertTrue(ret == 0) |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
164 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
|
165 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
|
166 |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
167 |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
168 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
|
169 |
|
6181
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
170 def testGet(self): |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
171 ''' 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
|
172 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
|
173 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
|
174 ''' |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
175 self.install_init() |
|
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 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
178 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
|
179 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
|
180 '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
|
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 out = out.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
184 print(out) |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
185 self.assertEqual(out, '1') |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
186 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
187 self.admin=AdminTool() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
188 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
|
189 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
|
190 '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
|
191 'superseder=1'] |
|
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 print(out) |
|
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 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
199 self.admin=AdminTool() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
200 with captured_output() as (out, err): |
|
7752
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
201 sys.argv=['main', '-i', self.dirname, 'create', 'issue', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
202 'title="bar foo bar"', 'assignedto=admin', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
203 'superseder=1,2'] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
204 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
205 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
206 self.assertEqual(ret, 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
207 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
208 print(out) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
209 self.assertEqual(out, '3') |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
210 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
211 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
212 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
|
213 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
|
214 'issue2' ] |
|
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, '2') |
|
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): |
|
7752
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
225 sys.argv=['main', '-i', self.dirname, '-d', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
226 'get', 'assignedto', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
227 'issue2' ] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
228 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
229 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
230 self.assertEqual(ret, 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
231 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
232 err = err.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
233 self.assertEqual(out, 'user2') |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
234 self.assertEqual(len(err), 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
235 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
236 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
237 with captured_output() as (out, err): |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
238 sys.argv=['main', '-i', self.dirname, '-d', '-S', ':', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
239 'get', 'assignedto', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
240 'issue2' ] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
241 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
242 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
243 self.assertEqual(ret, 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
244 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
245 err = err.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
246 self.assertEqual(out, 'user2') |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
247 self.assertEqual(len(err), 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
248 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
249 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
250 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
|
251 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
|
252 'issue2' ] |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
253 ret = self.admin.main() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
254 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
255 self.assertEqual(ret, 0) |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
256 out = out.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
257 err = err.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
258 self.assertEqual(out, "['1']") |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
259 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
|
260 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
261 self.admin=AdminTool() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
262 with captured_output() as (out, err): |
|
7752
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
263 sys.argv=['main', '-i', self.dirname, 'get', 'superseder', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
264 'issue3' ] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
265 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
266 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
267 self.assertEqual(ret, 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
268 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
269 err = err.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
270 self.assertEqual(out, "['1', '2']") |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
271 self.assertEqual(len(err), 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
272 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
273 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
274 with captured_output() as (out, err): |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
275 sys.argv=['main', '-i', self.dirname, '-d', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
276 'get', 'superseder', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
277 'issue3' ] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
278 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
279 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
280 self.assertEqual(ret, 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
281 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
282 err = err.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
283 self.assertEqual(out, "issue1\nissue2") |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
284 self.assertEqual(len(err), 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
285 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
286 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
287 with captured_output() as (out, err): |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
288 sys.argv=['main', '-i', self.dirname, '-c', '-d', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
289 'get', 'superseder', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
290 'issue3' ] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
291 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
292 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
293 self.assertEqual(ret, 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
294 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
295 err = err.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
296 self.assertEqual(out, "issue1,issue2") |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
297 self.assertEqual(len(err), 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
298 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
299 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
300 with captured_output() as (out, err): |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
301 sys.argv=['main', '-i', self.dirname, '-d', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
302 'get', 'title', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
303 'issue3' ] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
304 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
305 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
306 self.assertEqual(ret, 1) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
307 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
308 err = err.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
309 self.assertEqual(out.split('\n')[0], "Error: property title is not of type Multilink or Link so -d flag does not apply.") |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
310 self.assertEqual(len(err), 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
311 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
312 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
313 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
|
314 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
|
315 ret = self.admin.main() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
316 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
317 self.assertEqual(ret, 0) |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
318 out = out.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
319 err = err.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
320 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
|
321 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
|
322 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
323 self.admin=AdminTool() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
324 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
|
325 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
|
326 ret = self.admin.main() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
327 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
328 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
|
329 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
330 self.assertEqual(ret, 1) |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
331 out = out.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
332 err = err.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
333 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
|
334 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
|
335 |
| 6199 | 336 self.admin=AdminTool() |
| 337 with captured_output() as (out, err): | |
| 338 sys.argv=['main', '-i', self.dirname, 'get', 'title', 'issue'] | |
| 339 ret = self.admin.main() | |
| 340 | |
| 341 expected_err = 'Error: "issue" not a node designator' | |
| 342 | |
| 343 self.assertEqual(ret, 1) | |
| 344 out = out.getvalue().strip() | |
| 345 err = err.getvalue().strip() | |
| 346 self.assertEqual(out.index(expected_err), 0) | |
| 347 self.assertEqual(len(err), 0) | |
| 348 | |
|
7752
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
349 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
350 with captured_output() as (out, err): |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
351 sys.argv=['main', '-i', self.dirname, 'get', 'title', 'issue500'] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
352 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
353 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
354 expected_err = 'Error: no such issue node "500"' |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
355 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
356 self.assertEqual(ret, 1) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
357 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
358 err = err.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
359 print(out) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
360 self.assertEqual(out.index(expected_err), 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
361 self.assertEqual(len(err), 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
362 |
|
5713
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
363 def testInit(self): |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
364 self.admin=AdminTool() |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
365 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
|
366 ret = self.admin.main() |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
367 print(ret) |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
368 self.assertTrue(ret == 0) |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
369 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
|
370 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
|
371 |
|
7883
23b7669b2f48
test: fix path issues posix vs windows in admin functions.
John Rouillard <rouilj@ieee.org>
parents:
7870
diff
changeset
|
372 nopath= '/tmp/noSuchDirectory/nodir' |
|
23b7669b2f48
test: fix path issues posix vs windows in admin functions.
John Rouillard <rouilj@ieee.org>
parents:
7870
diff
changeset
|
373 norealpath = os.path.realpath(nopath + "/..") |
|
7392
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
374 self.admin=AdminTool() |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
375 with captured_output() as (out, err): |
|
7883
23b7669b2f48
test: fix path issues posix vs windows in admin functions.
John Rouillard <rouilj@ieee.org>
parents:
7870
diff
changeset
|
376 sys.argv=['main', '-i', nopath, 'install', 'classic', self.backend] |
|
7392
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
377 ret = self.admin.main() |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
378 |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
379 out = out.getvalue().strip() |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
380 print(ret) |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
381 print(out) |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
382 self.assertEqual(ret, 1) |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
383 self.assertIn('Error: Instance home parent directory ' |
|
7883
23b7669b2f48
test: fix path issues posix vs windows in admin functions.
John Rouillard <rouilj@ieee.org>
parents:
7870
diff
changeset
|
384 '"%s" does not exist' % norealpath, out) |
|
7392
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
385 |
|
5762
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
386 def testInitWithConfig_ini(self): |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
387 from roundup.configuration import CoreConfig |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
388 self.admin=AdminTool() |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
389 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
|
390 # create a config_ini.ini file in classic template |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
391 templates=self.admin.listTemplates() |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
392 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
|
393 config_ini_path = templates['classic']['path'] + '/config_ini.ini' |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
394 config_ini_file = open(config_ini_path, "w") |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
395 config_ini_file.write(config_ini_content) |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
396 config_ini_file.close() |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
397 |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
398 try: |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
399 ret = self.admin.main() |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
400 finally: |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
401 try: |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
402 # ignore file not found |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
403 os.remove(config_ini_path) |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
404 except OSError as e: # FileNotFound exception under py3 |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
405 if e.errno == 2: |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
406 pass |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
407 else: |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
408 raise |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
409 |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
410 print(ret) |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
411 self.assertTrue(ret == 0) |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
412 self.assertTrue(os.path.isfile(self.dirname + "/config.ini")) |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
413 self.assertTrue(os.path.isfile(self.dirname + "/schema.py")) |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
414 config=CoreConfig(self.dirname) |
|
7883
23b7669b2f48
test: fix path issues posix vs windows in admin functions.
John Rouillard <rouilj@ieee.org>
parents:
7870
diff
changeset
|
415 self.assertEqual(config['MAIL_DEBUG'], |
|
23b7669b2f48
test: fix path issues posix vs windows in admin functions.
John Rouillard <rouilj@ieee.org>
parents:
7870
diff
changeset
|
416 os.path.normpath(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
|
417 |
|
7752
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
418 def testList(self): |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
419 ''' Note the tests will fail if you run this under pdb. |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
420 the context managers capture the pdb prompts and this screws |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
421 up the stdout strings with (pdb) prefixed to the line. |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
422 ''' |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
423 self.install_init() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
424 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
425 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
426 with captured_output() as (out, err): |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
427 sys.argv=['main', '-i', self.dirname, 'list', 'user', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
428 'username' ] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
429 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
430 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
431 self.assertEqual(ret, 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
432 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
433 print(out) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
434 self.assertEqual(out, '1: admin\n 2: anonymous') |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
435 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
436 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
437 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
438 with captured_output() as (out, err): |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
439 sys.argv=['main', '-i', self.dirname, '-c', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
440 'list', 'user' ] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
441 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
442 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
443 self.assertEqual(ret, 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
444 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
445 print(out) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
446 self.assertEqual(out, '1,2') |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
447 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
448 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
449 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
450 with captured_output() as (out, err): |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
451 sys.argv=['main', '-i', self.dirname, '-c', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
452 'list', 'user', 'username' ] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
453 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
454 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
455 self.assertEqual(ret, 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
456 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
457 print(out) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
458 self.assertEqual(out, 'admin,anonymous') |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
459 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
460 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
461 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
462 with captured_output() as (out, err): |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
463 sys.argv=['main', '-i', self.dirname, '-c', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
464 'list', 'user', 'roles' ] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
465 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
466 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
467 self.assertEqual(ret, 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
468 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
469 print(out) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
470 self.assertEqual(out, 'Admin,Anonymous') |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
471 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
472 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
473 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
474 with captured_output() as (out, err): |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
475 sys.argv=['main', '-i', self.dirname, 'list', 'user', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
476 'foo' ] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
477 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
478 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
479 self.assertEqual(ret, 1) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
480 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
481 print(out) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
482 self.assertEqual(out.split('\n')[0], |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
483 'Error: user has no property "foo"') |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
484 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
485 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
486 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
487 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
488 with captured_output() as (out, err): |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
489 sys.argv=['main', '-i', self.dirname, '-c', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
490 'list', 'user', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
491 'bar' ] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
492 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
493 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
494 self.assertEqual(ret, 1) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
495 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
496 print(out) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
497 self.assertEqual(out.split('\n')[0], |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
498 'Error: user has no property "bar"') |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
499 |
|
6176
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
500 def testFind(self): |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
501 ''' 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
|
502 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
|
503 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
|
504 ''' |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
505 self.admin=AdminTool() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
506 self.install_init() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
507 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
508 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
|
509 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
|
510 '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
|
511 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
|
512 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
513 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
|
514 print(out) |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
515 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
|
516 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
517 self.admin=AdminTool() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
518 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
|
519 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
|
520 '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
|
521 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
|
522 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
523 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
|
524 print(out) |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
525 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
|
526 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
527 self.admin=AdminTool() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
528 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
|
529 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
|
530 'assignedto=1'] |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
531 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
|
532 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
533 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
|
534 print(out) |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
535 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
|
536 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
537 # 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
|
538 self.admin=AdminTool() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
539 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
|
540 ''' 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
|
541 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
|
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, 'find', 'issue', |
|
6176
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
544 'assignedto=1,2'] |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
545 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
|
546 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
547 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
|
548 print(out) |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
549 # 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
|
550 # 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
|
551 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
|
552 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
553 # 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
|
554 self.admin=AdminTool() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
555 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
|
556 ''' 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
|
557 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
|
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, 'find', 'issue', |
|
6176
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
560 'assignedto=admin,anonymous'] |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
561 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
|
562 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
563 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
|
564 print(out) |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
565 # 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
|
566 # 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
|
567 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
|
568 |
|
7752
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
569 # Reopen the db closed by previous filter call |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
570 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
571 with captured_output() as (out, err): |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
572 ''' 1,2 should return all entries that have assignedto |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
573 either admin or anonymous |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
574 ''' |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
575 sys.argv=['main', '-i', self.dirname, '-c', '-d', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
576 'find', 'issue', 'assignedto=admin,anonymous'] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
577 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
578 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
579 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
580 print(out) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
581 self.assertEqual(out, "issue1,issue2") |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
582 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
583 # Reopen the db closed by previous filter call |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
584 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
585 with captured_output() as (out, err): |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
586 ''' 1,2 should return all entries that have assignedto |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
587 either admin or anonymous |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
588 ''' |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
589 sys.argv=['main', '-i', self.dirname, '-S', ':', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
590 'find', 'issue', 'assignedto=admin,anonymous'] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
591 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
592 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
593 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
594 print(out) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
595 self.assertEqual(out, "1:2") |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
596 |
|
6188
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
597 def testGenconfigUpdate(self): |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
598 ''' 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
|
599 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
|
600 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
|
601 ''' |
|
7182
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
602 import filecmp |
|
6188
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
603 |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
604 self.admin=AdminTool() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
605 self.install_init() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
606 |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
607 with captured_output() as (out, err): |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
608 sys.argv=['main', '-i', self.dirname, 'genconfig'] |
|
6188
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
609 ret = self.admin.main() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
610 |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
611 out = out.getvalue().strip() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
612 print(out) |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
613 expected = "Not enough arguments supplied" |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
614 self.assertTrue(expected in out) |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
615 |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
616 # Reopen the db closed by previous call |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
617 self.admin=AdminTool() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
618 |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
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, 'genconfig', |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
621 self.dirname + "/config2.ini"] |
|
6188
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
622 ret = self.admin.main() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
623 |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
624 out = out.getvalue().strip() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
625 print(out) |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
626 # FIXME get better successful test later. |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
627 expected = "" |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
628 self.assertTrue(expected in out) |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
629 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
|
630 # 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
|
631 # 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
|
632 # to be customized. |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
633 #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
|
634 # self.dirname + "/config.ini")) |
|
6188
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
635 |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
636 # Reopen the db closed by previous call |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
637 self.admin=AdminTool() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
638 |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
639 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
|
640 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
|
641 self.dirname + "/foo2.ini"] |
|
6188
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
642 ret = self.admin.main() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
643 |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
644 out = out.getvalue().strip() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
645 print(out) |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
646 # FIXME get better successful test later. |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
647 expected = "" |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
648 self.assertTrue(expected in out) |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
649 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
|
650 |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
651 # 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
|
652 # so filecmp passes. |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
653 normalize_file(self.dirname + "/foo2.ini", |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
654 [ '# Autogenerated at' ]) |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
655 normalize_file(self.dirname + "/config.ini", |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
656 [ '# Autogenerated at' ]) |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
657 |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
658 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
|
659 self.dirname + "/foo2.ini")) |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
660 |
|
7204
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
661 def testUpdateconfigPbkdf2(self): |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
662 ''' 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
|
663 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
|
664 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
|
665 ''' |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
666 import filecmp |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
667 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
668 self.admin=AdminTool() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
669 self.install_init() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
670 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
671 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
|
672 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
|
673 self.dirname + "/config2.ini"] |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
674 ret = self.admin.main() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
675 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
676 out = out.getvalue().strip() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
677 print(out) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
678 self.assertEqual(out, "") |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
679 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
|
680 # 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
|
681 # so filecmp passes. |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
682 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
|
683 [ '# Autogenerated at' ]) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
684 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
|
685 [ '# Autogenerated at' ]) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
686 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
687 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
|
688 self.dirname + "/config2.ini")) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
689 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
690 # 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
|
691 self.admin=AdminTool() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
692 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
693 ### 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
|
694 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
|
695 "= 2000000", "= 10000") |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
696 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
|
697 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
|
698 self.dirname + "/config2.ini"] |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
699 ret = self.admin.main() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
700 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
701 out = out.getvalue().strip() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
702 print(out) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
703 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
|
704 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
705 self.assertIn(expected, out) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
706 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
|
707 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
|
708 "^password_.*= 2000000$"), |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
709 "password_pbkdf2_default_rounds = 2000000") |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
710 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
711 # 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
|
712 self.admin=AdminTool() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
713 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
714 ### 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
|
715 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
|
716 "= 10000", "= 10001") |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
717 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
|
718 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
|
719 self.dirname + "/config2.ini"] |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
720 ret = self.admin.main() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
721 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
722 out = out.getvalue().strip() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
723 print(out) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
724 expected = ("Update 'password_pbkdf2_default_rounds' to a number " |
|
7870
fe77e4325084
test: fix test to change in message.
John Rouillard <rouilj@ieee.org>
parents:
7803
diff
changeset
|
725 "equal to or larger\n than 2000000.") |
|
7204
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
726 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
727 self.assertIn(expected, out) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
728 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
|
729 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
|
730 "^password_.*= 10001$"), |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
731 "password_pbkdf2_default_rounds = 10001") |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
732 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
733 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
734 # 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
|
735 self.admin=AdminTool() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
736 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
737 ### 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
|
738 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
|
739 "= 10001", "= 2000001") |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
740 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
|
741 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
|
742 self.dirname + "/config2.ini"] |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
743 ret = self.admin.main() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
744 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
745 out = out.getvalue().strip() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
746 print(out) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
747 expected = "" |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
748 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
749 self.assertEqual(expected, out) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
750 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
|
751 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
|
752 "^password_.*= 2000001$"), |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
753 "password_pbkdf2_default_rounds = 2000001") |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
754 |
|
6188
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
755 |
|
6186
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
756 def testCliParse(self): |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
757 ''' 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
|
758 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
|
759 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
|
760 ''' |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
761 self.admin=AdminTool() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
762 self.install_init() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
763 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
764 # 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
|
765 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
766 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
|
767 ''' 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
|
768 report error. |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
769 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
770 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
|
771 'assignedto=1'] |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
772 ret = self.admin.main() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
773 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
774 out = out.getvalue().strip() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
775 print(out) |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
776 expected="[ '1' ]" |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
777 self.assertTrue(expected, out) |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
778 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
779 # 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
|
780 self.admin=AdminTool() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
781 # test multiple matches |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
782 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
|
783 ''' 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
|
784 report error. |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
785 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
786 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
|
787 'assignedto'] |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
788 ret = self.admin.main() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
789 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
790 out = out.getvalue().strip() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
791 print(out) |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
792 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
|
793 self.assertEqual(expected, out) |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
794 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
795 # 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
|
796 self.admin=AdminTool() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
797 # 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
|
798 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
|
799 ''' 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
|
800 report error. |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
801 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
802 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
|
803 'assignedto'] |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
804 ret = self.admin.main() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
805 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
806 out = out.getvalue().strip() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
807 print(out) |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
808 expected=('Unknown command "xyzzy" ' |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
809 '("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
|
810 self.assertEqual(expected, out) |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
811 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
812 # 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
|
813 self.admin=AdminTool() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
814 # 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
|
815 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
|
816 ''' 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
|
817 report error. |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
818 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
819 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
|
820 'assignedto'] |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
821 ret = self.admin.main() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
822 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
823 out = out.getvalue().strip() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
824 print(out) |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
825 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
|
826 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
|
827 |
|
6177
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
828 def testFilter(self): |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
829 ''' 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
|
830 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
|
831 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
|
832 ''' |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
833 self.admin=AdminTool() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
834 self.install_init() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
835 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
836 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
|
837 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
|
838 'title="foo bar"', 'assignedto=admin' ] |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
839 ret = self.admin.main() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
840 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
841 out = out.getvalue().strip() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
842 print(out) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
843 self.assertEqual(out, '1') |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
844 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
845 self.admin=AdminTool() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
846 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
|
847 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
|
848 'title="bar foo bar"', 'assignedto=anonymous' ] |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
849 ret = self.admin.main() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
850 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
851 out = out.getvalue().strip() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
852 print(out) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
853 self.assertEqual(out, '2') |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
854 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
855 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
856 # Reopen the db closed by previous filter call |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
857 # test string - one results, one value, substring |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
858 self.admin=AdminTool() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
859 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
|
860 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
|
861 'username=admin'] |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
862 ret = self.admin.main() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
863 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
864 out = out.getvalue().strip() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
865 print(out) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
866 self.assertEqual(out, "['1']") |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
867 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
868 # Reopen the db closed by previous filter call |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
869 # test string - two results, two values, substring |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
870 self.admin=AdminTool() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
871 with captured_output() as (out, err): |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
872 ''' 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
|
873 so admin or anonymous |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
874 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
875 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
|
876 'username=a,n'] |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
877 ret = self.admin.main() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
878 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
879 out = out.getvalue().strip() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
880 print(out) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
881 # out can be "['2', '1']" or "['1', '2']" |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
882 # 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
|
883 self.assertEqual(sorted(eval(out)), ['1', '2']) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
884 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
885 # Reopen the db closed by previous filter call |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
886 # test string - one result, two values, substring |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
887 self.admin=AdminTool() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
888 with captured_output() as (out, err): |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
889 ''' 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
|
890 so anonymous |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
891 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
892 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
|
893 'username=a,y'] |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
894 ret = self.admin.main() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
895 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
896 out = out.getvalue().strip() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
897 print(out) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
898 self.assertEqual(out, "['2']") |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
899 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
900 # Reopen the db closed by previous filter call |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
901 # test string - no results |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
902 self.admin=AdminTool() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
903 with captured_output() as (out, err): |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
904 ''' will return empty set as admin!=anonymous |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
905 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
906 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
|
907 'username=admin,anonymous'] |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
908 ret = self.admin.main() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
909 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
910 out = out.getvalue().strip() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
911 print(out) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
912 self.assertEqual(out, "[]") |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
913 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
914 # Reopen the db closed by previous filter call |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
915 # test link using ids |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
916 self.admin=AdminTool() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
917 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
|
918 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
|
919 'assignedto=1,2'] |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
920 ret = self.admin.main() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
921 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
922 out = out.getvalue().strip() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
923 print(out) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
924 self.assertEqual(sorted(eval(out)), ['1', '2']) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
925 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
926 # Reopen the db closed by previous filter call |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
927 # test link using names |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
928 self.admin=AdminTool() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
929 with captured_output() as (out, err): |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
930 ''' will return empty set as admin!=anonymous |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
931 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
932 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
|
933 'assignedto=admin,anonymous'] |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
934 ret = self.admin.main() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
935 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
936 out = out.getvalue().strip() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
937 print(out) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
938 self.assertEqual(sorted(eval(out)), ['1', '2']) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
939 |
|
6250
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
940 # 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
|
941 # |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
942 # case: transitive property valid match |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
943 self.admin=AdminTool() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
944 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
|
945 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
|
946 'assignedto.roles=Anonymous'] |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
947 ret = self.admin.main() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
948 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
949 out = out.getvalue().strip() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
950 print(out) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
951 self.assertEqual(out, "['2']") |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
952 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
953 # 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
|
954 # self.admin=AdminTool() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
955 # case: transitive propery invalid prop |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
956 self.admin=AdminTool() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
957 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
|
958 ''' 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
|
959 report error. |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
960 ''' |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
961 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
|
962 'assignedto.badprop=Admin'] |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
963 ret = self.admin.main() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
964 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
965 out = out.getvalue().strip() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
966 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
|
967 print(out[0:len(expected)]) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
968 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
|
969 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
970 # 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
|
971 # |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
972 # case: transitive property invalid match |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
973 self.admin=AdminTool() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
974 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
|
975 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
|
976 'filter', 'issue', |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
977 'assignedto.username=NoNAme'] |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
978 ret = self.admin.main() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
979 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
980 out = out.getvalue().strip() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
981 print("me: " + out) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
982 print(err.getvalue().strip()) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
983 self.assertEqual(out, "[]") |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
984 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
985 # 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
|
986 # |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
987 # case: transitive property invalid match |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
988 self.admin=AdminTool() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
989 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
|
990 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
|
991 'filter', 'issue', |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
992 'assignedto.username=NoNAme'] |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
993 ret = self.admin.main() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
994 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
995 out = out.getvalue().strip() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
996 print("me: " + out) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
997 print(err.getvalue().strip()) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
998 self.assertEqual(out, "") |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
999 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1000 # 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
|
1001 # |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1002 # case: transitive property invalid match |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1003 self.admin=AdminTool() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1004 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
|
1005 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
|
1006 'filter', 'issue', |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1007 'assignedto.username=A'] |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1008 ret = self.admin.main() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1009 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1010 out = out.getvalue().strip() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1011 print("me: " + out) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1012 print(err.getvalue().strip()) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1013 self.assertEqual(out, "1,2") |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1014 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1015 # 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
|
1016 # |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1017 # case: transitive property invalid match |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1018 self.admin=AdminTool() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1019 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
|
1020 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
|
1021 'filter', 'issue', |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1022 'assignedto.username=A'] |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1023 ret = self.admin.main() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1024 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1025 out = out.getvalue().strip() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1026 print("me: " + out) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1027 print(err.getvalue().strip()) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1028 self.assertEqual(out, "1 2") |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1029 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1030 # 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
|
1031 # |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1032 # case: transitive property invalid match |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1033 self.admin=AdminTool() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1034 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
|
1035 sys.argv=['main', '-i', self.dirname, '-S', ':', |
|
6251
b303db7f384f
Test designator code path
John Rouillard <rouilj@ieee.org>
parents:
6250
diff
changeset
|
1036 '-d', 'filter', 'issue', |
|
6250
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1037 'assignedto.username=A'] |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1038 ret = self.admin.main() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1039 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1040 out = out.getvalue().strip() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1041 print("me: " + out) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1042 print(err.getvalue().strip()) |
|
6251
b303db7f384f
Test designator code path
John Rouillard <rouilj@ieee.org>
parents:
6250
diff
changeset
|
1043 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
|
1044 |
|
7752
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1045 # Reopen the db closed by previous filter call |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1046 # |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1047 # case: transitive property invalid match |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1048 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1049 with captured_output() as (out, err): |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1050 sys.argv=['main', '-i', self.dirname, |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1051 '-d', 'filter', 'issue', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1052 'assignedto.username=A'] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1053 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1054 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1055 print("me: " + out) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1056 print(err.getvalue().strip()) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1057 self.assertEqual(out, "['issue1', 'issue2']") |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1058 |
|
7254
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1059 def testPragma_reopen_tracker(self): |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1060 """test that _reopen_tracker works. |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1061 """ |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1062 if self.backend not in ['anydbm']: |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1063 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
|
1064 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1065 orig_input = AdminTool.my_input |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1066 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1067 # 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
|
1068 # and to get "Reopening tracker" verbose log output |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1069 inputs = iter(["pragma verbose=true", "pragma list", "quit"]) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1070 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1071 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1072 self.install_init() |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1073 self.admin=AdminTool() |
|
7803
2746337ded4c
fix: disable history file changes when testing
John Rouillard <rouilj@ieee.org>
parents:
7802
diff
changeset
|
1074 self.admin.settings['history_features'] = 2 |
|
7254
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1075 sys.argv=['main', '-i', self.dirname] |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1076 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1077 with captured_output() as (out, err): |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1078 ret = self.admin.main() |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1079 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1080 out = out.getvalue().strip().split('\n') |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1081 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1082 print(ret) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1083 self.assertTrue(ret == 0) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1084 expected = ' _reopen_tracker=False' |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1085 self.assertIn(expected, out) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1086 self.assertIn('descriptions...', out[-1]) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1087 self.assertNotIn('Reopening tracker', out) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1088 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1089 # ----- |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1090 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
|
1091 "pragma list", "quit"]) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1092 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1093 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1094 self.install_init() |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1095 self.admin=AdminTool() |
|
7803
2746337ded4c
fix: disable history file changes when testing
John Rouillard <rouilj@ieee.org>
parents:
7802
diff
changeset
|
1096 self.admin.settings['history_features'] = 2 |
|
7254
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1097 sys.argv=['main', '-i', self.dirname] |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1098 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1099 with captured_output() as (out, err): |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1100 ret = self.admin.main() |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1101 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1102 out = out.getvalue().strip().split('\n') |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1103 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1104 print(ret) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1105 self.assertTrue(ret == 0) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1106 self.assertEqual('Reopening tracker', out[2]) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1107 expected = ' _reopen_tracker=True' |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1108 self.assertIn(expected, out) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1109 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1110 # ----- |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1111 AdminTool.my_input = orig_input |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1112 |
|
7252
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1113 def testPragma(self): |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1114 """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
|
1115 commands. |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1116 """ |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1117 if self.backend not in ['anydbm']: |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1118 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
|
1119 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1120 orig_input = AdminTool.my_input |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1121 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1122 for i in ["oN", "1", "yeS", "True"]: |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1123 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
|
1124 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1125 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1126 self.install_init() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1127 self.admin=AdminTool() |
|
7803
2746337ded4c
fix: disable history file changes when testing
John Rouillard <rouilj@ieee.org>
parents:
7802
diff
changeset
|
1128 self.admin.settings['history_features'] = 2 |
|
7252
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1129 sys.argv=['main', '-i', self.dirname] |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1130 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1131 with captured_output() as (out, err): |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1132 ret = self.admin.main() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1133 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1134 out = out.getvalue().strip().split('\n') |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1135 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1136 print(ret) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1137 self.assertTrue(ret == 0) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1138 expected = ' verbose=True' |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1139 self.assertIn(expected, out) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1140 self.assertIn('descriptions...', out[-1]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1141 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1142 # ----- |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1143 for i in ["oFf", "0", "NO", "FalSe"]: |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1144 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
|
1145 "pragma list", "quit"]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1146 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1147 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1148 self.install_init() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1149 self.admin=AdminTool() |
|
7803
2746337ded4c
fix: disable history file changes when testing
John Rouillard <rouilj@ieee.org>
parents:
7802
diff
changeset
|
1150 self.admin.settings['history_features'] = 2 |
|
7252
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1151 sys.argv=['main', '-i', self.dirname] |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1152 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1153 with captured_output() as (out, err): |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1154 ret = self.admin.main() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1155 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1156 out = out.getvalue().strip().split('\n') |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1157 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1158 print(ret) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1159 self.assertTrue(ret == 0) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1160 expected = ' verbose=False' |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1161 self.assertIn(expected, out) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1162 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1163 # ----- test syntax errors |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1164 inputs = iter(["pragma", "pragma arg", |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1165 "pragma foo=3","quit"]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1166 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1167 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1168 self.install_init() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1169 self.admin=AdminTool() |
|
7803
2746337ded4c
fix: disable history file changes when testing
John Rouillard <rouilj@ieee.org>
parents:
7802
diff
changeset
|
1170 self.admin.settings['history_features'] = 2 |
|
7252
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1171 sys.argv=['main', '-i', self.dirname] |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1172 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1173 with captured_output() as (out, err): |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1174 ret = self.admin.main() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1175 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1176 out = out.getvalue().strip().split('\n') |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1177 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1178 print(ret) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1179 self.assertTrue(ret == 0) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1180 expected = 'Error: Not enough arguments supplied' |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1181 self.assertIn(expected, out) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1182 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
|
1183 self.assertIn(expected, out) |
|
7752
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1184 expected = 'Error: Unknown setting foo. Try "pragma list".' |
|
7252
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1185 self.assertIn(expected, out) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1186 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1187 # ----- |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1188 inputs = iter(["pragma verbose=foo", "quit"]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1189 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1190 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1191 self.install_init() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1192 self.admin=AdminTool() |
|
7803
2746337ded4c
fix: disable history file changes when testing
John Rouillard <rouilj@ieee.org>
parents:
7802
diff
changeset
|
1193 self.admin.settings['history_features'] = 2 |
|
7252
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1194 sys.argv=['main', '-i', self.dirname] |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1195 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1196 with captured_output() as (out, err): |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1197 ret = self.admin.main() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1198 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1199 out = out.getvalue().strip().split('\n') |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1200 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1201 print(ret) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1202 self.assertTrue(ret == 0) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1203 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
|
1204 self.assertIn(expected, out) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1205 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1206 # ----- |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1207 inputs = iter(["pragma verbose=on", "pragma _inttest=5", |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1208 "pragma list", "quit"]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1209 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1210 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1211 self.install_init() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1212 self.admin=AdminTool() |
|
7803
2746337ded4c
fix: disable history file changes when testing
John Rouillard <rouilj@ieee.org>
parents:
7802
diff
changeset
|
1213 self.admin.settings['history_features'] = 2 |
|
7252
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1214 sys.argv=['main', '-i', self.dirname] |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1215 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1216 with captured_output() as (out, err): |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1217 ret = self.admin.main() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1218 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1219 out = out.getvalue().strip().split('\n') |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1220 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1221 print(ret) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1222 self.assertTrue(ret == 0) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1223 expected = ' _inttest=5' |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1224 self.assertIn(expected, out) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1225 self.assertIn('descriptions...', out[-1]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1226 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1227 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1228 # ----- |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1229 inputs = iter(["pragma verbose=on", "pragma _inttest=fred", |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1230 "pragma list", "quit"]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1231 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1232 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1233 self.install_init() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1234 self.admin=AdminTool() |
|
7803
2746337ded4c
fix: disable history file changes when testing
John Rouillard <rouilj@ieee.org>
parents:
7802
diff
changeset
|
1235 self.admin.settings['history_features'] = 2 |
|
7252
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1236 sys.argv=['main', '-i', self.dirname] |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1237 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1238 with captured_output() as (out, err): |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1239 ret = self.admin.main() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1240 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1241 out = out.getvalue().strip().split('\n') |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1242 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1243 print(ret) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1244 self.assertTrue(ret == 0) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1245 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
|
1246 self.assertIn(expected, out) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1247 self.assertIn('descriptions...', out[-1]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1248 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1249 # ----- |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1250 inputs = iter(["pragma indexer_backend=whoosh", "pragma list", |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1251 "quit"]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1252 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1253 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1254 self.install_init() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1255 self.admin=AdminTool() |
|
7803
2746337ded4c
fix: disable history file changes when testing
John Rouillard <rouilj@ieee.org>
parents:
7802
diff
changeset
|
1256 self.admin.settings['history_features'] = 2 |
|
7252
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1257 sys.argv=['main', '-i', self.dirname] |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1258 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1259 with captured_output() as (out, err): |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1260 ret = self.admin.main() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1261 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1262 out = out.getvalue().strip().split('\n') |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1263 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1264 print(ret) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1265 expected = ' indexer_backend=whoosh' |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1266 self.assertIn(expected, out) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1267 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1268 # ----- |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1269 inputs = iter(["pragma _floattest=4.5", "quit"]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1270 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1271 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1272 self.install_init() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1273 self.admin=AdminTool() |
|
7803
2746337ded4c
fix: disable history file changes when testing
John Rouillard <rouilj@ieee.org>
parents:
7802
diff
changeset
|
1274 self.admin.settings['history_features'] = 2 |
|
7252
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1275 sys.argv=['main', '-i', self.dirname] |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1276 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1277 with captured_output() as (out, err): |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1278 ret = self.admin.main() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1279 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1280 out = out.getvalue().strip().split('\n') |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1281 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1282 print(ret) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1283 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
|
1284 self.assertIn(expected, out) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1285 |
|
7543
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1286 |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1287 # ----- |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1288 inputs = iter(["pragma display_protected=yes", |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1289 "display user1", |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1290 "quit"]) |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1291 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1292 |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1293 self.install_init() |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1294 self.admin=AdminTool() |
|
7803
2746337ded4c
fix: disable history file changes when testing
John Rouillard <rouilj@ieee.org>
parents:
7802
diff
changeset
|
1295 self.admin.settings['history_features'] = 2 |
|
7543
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1296 sys.argv=['main', '-i', self.dirname] |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1297 |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1298 with captured_output() as (out, err): |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1299 ret = self.admin.main() |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1300 |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1301 out = out.getvalue().strip() |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1302 |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1303 print(ret) |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1304 expected = '\n*creation: ' |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1305 self.assertIn(expected, out) |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1306 |
|
7252
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1307 # ----- |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1308 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
|
1309 |
|
7395
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1310 def testReindex(self): |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1311 ''' Note the tests will fail if you run this under pdb. |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1312 the context managers capture the pdb prompts and this screws |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1313 up the stdout strings with (pdb) prefixed to the line. |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1314 ''' |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1315 self.install_init() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1316 |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1317 # create an issue |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1318 self.admin=AdminTool() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1319 sys.argv=['main', '-i', self.dirname, 'create', 'issue', |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1320 'title="foo bar"', 'assignedto=admin' ] |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1321 ret = self.admin.main() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1322 |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1323 # reindex everything |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1324 self.admin=AdminTool() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1325 with captured_output() as (out, err): |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1326 sys.argv=['main', '-i', self.dirname, 'reindex'] |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1327 ret = self.admin.main() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1328 out = out.getvalue().strip() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1329 print(len(out)) |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1330 print(repr(out)) |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1331 # make sure priority is being reindexed |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1332 self.assertIn('Reindex priority 40%', out) |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1333 |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1334 |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1335 # reindex whole class |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1336 self.admin=AdminTool() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1337 with captured_output() as (out, err): |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1338 sys.argv=['main', '-i', self.dirname, 'reindex', 'issue'] |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1339 ret = self.admin.main() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1340 |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1341 out = out.getvalue().strip() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1342 print(len(out)) |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1343 print(repr(out)) |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1344 self.assertEqual(out, |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1345 'Reindex issue 0% \rReindex issue 100% \rReindex issue done') |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1346 self.assertEqual(len(out), 170) |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1347 |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1348 # reindex one item |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1349 self.admin=AdminTool() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1350 with captured_output() as (out, err): |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1351 sys.argv=['main', '-i', self.dirname, 'reindex', 'issue1'] |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1352 ret = self.admin.main() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1353 |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1354 out = out.getvalue().strip() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1355 print(len(out)) |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1356 print(repr(out)) |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1357 # no output when reindexing just one item |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1358 self.assertEqual(out, '') |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1359 |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1360 # reindex range |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1361 self.admin=AdminTool() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1362 with captured_output() as (out, err): |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1363 sys.argv=['main', '-i', self.dirname, 'reindex', 'issue:1-4'] |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1364 ret = self.admin.main() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1365 |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1366 out = out.getvalue().strip() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1367 print(repr(out)) |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1368 self.assertIn('no such item "issue3"', out) |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1369 |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1370 # reindex bad class |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1371 self.admin=AdminTool() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1372 with captured_output() as (out, err): |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1373 sys.argv=['main', '-i', self.dirname, 'reindex', 'issue1-4'] |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1374 ret = self.admin.main() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1375 |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1376 out = out.getvalue().strip() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1377 print(repr(out)) |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1378 self.assertIn('Error: no such class "issue1-4"', out) |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1379 |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1380 # reindex bad item |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1381 self.admin=AdminTool() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1382 with captured_output() as (out, err): |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1383 sys.argv=['main', '-i', self.dirname, 'reindex', 'issue14'] |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1384 ret = self.admin.main() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1385 |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1386 out = out.getvalue().strip() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1387 print(repr(out)) |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1388 self.assertIn('Error: no such item "issue14"', out) |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1389 |
| 6199 | 1390 def disabletestHelpInitopts(self): |
| 1391 | |
| 1392 ''' Note the tests will fail if you run this under pdb. | |
| 1393 the context managers capture the pdb prompts and this screws | |
| 1394 up the stdout strings with (pdb) prefixed to the line. | |
| 1395 ''' | |
| 1396 self.install_init() | |
| 1397 self.admin=AdminTool() | |
| 1398 | |
| 1399 with captured_output() as (out, err): | |
| 1400 sys.argv=['main', '-i', self.dirname, 'help', 'initopts'] | |
| 1401 ret = self.admin.main() | |
| 1402 | |
| 1403 out = out.getvalue().strip() | |
| 1404 expected = [ | |
| 1405 'Templates: minimal, jinja2, classic, responsive, devel', | |
| 1406 'Back ends: anydbm, sqlite' | |
| 1407 ] | |
| 1408 print(out) | |
| 1409 self.assertTrue(expected[0] in out) | |
| 1410 self.assertTrue("Back ends:" in out) | |
| 1411 | |
|
7650
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1412 def testSecurityListOne(self): |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1413 self.install_init() |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1414 self.admin=AdminTool() |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1415 |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1416 with captured_output() as (out, err): |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1417 # make sure UsEr returns result for user. Roles are |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1418 # lower cased interally |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1419 sys.argv=['main', '-i', self.dirname, 'security', "user" ] |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1420 ret = self.admin.main() |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1421 |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1422 result = """Role "user": |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1423 User may use the email interface (Email Access) |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1424 User may access the rest interface (Rest Access) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1425 User may access the web interface (Web Access) |
|
7650
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1426 User may access the xmlrpc interface (Xmlrpc Access) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1427 User is allowed to create file (Create for "file" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1428 User is allowed to edit file (Edit for "file" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1429 User is allowed to access file (View for "file" only) |
|
7650
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1430 User is allowed to create issue (Create for "issue" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1431 User is allowed to edit issue (Edit for "issue" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1432 User is allowed to access issue (View for "issue" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1433 User is allowed to create keyword (Create for "keyword" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1434 User is allowed to edit keyword (Edit for "keyword" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1435 User is allowed to access keyword (View for "keyword" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1436 User is allowed to create msg (Create for "msg" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1437 User is allowed to edit msg (Edit for "msg" only) |
|
7650
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1438 User is allowed to access msg (View for "msg" only) |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1439 User is allowed to access priority (View for "priority" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1440 User is allowed to create queries (Create for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1441 User is allowed to edit their queries (Edit for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1442 User is allowed to restore their queries (Restore for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1443 User is allowed to retire their queries (Retire for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1444 (Search for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1445 User is allowed to view their own and public queries (View for "query" only) |
|
7650
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1446 User is allowed to access status (View for "status" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1447 User is allowed to edit their own user details (Edit for "user": ('username', 'password', 'address', 'realname', 'phone', 'organisation', 'alternate_addresses', 'queries', 'timezone') only) |
|
7650
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1448 (View for "user": ('id', 'organisation', 'phone', 'realname', 'timezone', 'username') only) |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1449 User is allowed to view their own user details (View for "user" only) |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1450 """ |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1451 print(out.getvalue()) |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1452 |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1453 self.assertEqual(result, out.getvalue()) |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1454 self.assertEqual(ret, 0) |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1455 |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1456 |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1457 # test 2 all role names are lower case, make sure |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1458 # any role name is correctly lower cased |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1459 self.admin=AdminTool() |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1460 with captured_output() as (out, err): |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1461 sys.argv=['main', '-i', self.dirname, 'security', "UsEr" ] |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1462 ret = self.admin.main() |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1463 |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1464 print(out.getvalue()) |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1465 |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1466 self.assertEqual(result, out.getvalue()) |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1467 self.assertEqual(ret, 0) |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1468 |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1469 # test 3 Check error if role does not exist |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1470 self.admin=AdminTool() |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1471 with captured_output() as (out, err): |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1472 sys.argv=['main', '-i', self.dirname, 'security', "NoSuch Role" ] |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1473 ret = self.admin.main() |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1474 |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1475 result='No such Role "NoSuch Role"\n' |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1476 print('>', out.getvalue()) |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1477 |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1478 self.assertEqual(result, out.getvalue()) |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1479 self.assertEqual(ret, 1) |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1480 |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1481 |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1482 def testSecurityListAll(self): |
|
6393
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1483 ''' 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
|
1484 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
|
1485 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
|
1486 ''' |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1487 self.install_init() |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1488 self.admin=AdminTool() |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1489 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1490 with captured_output() as (out, err): |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1491 sys.argv=['main', '-i', self.dirname, 'security' ] |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1492 ret = self.admin.main() |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1493 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1494 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
|
1495 New Email users get the Role "User" |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1496 Role "admin": |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1497 User may create everything (Create) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1498 User may edit everything (Edit) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1499 User may use the email interface (Email Access) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1500 User may access the rest interface (Rest Access) |
|
6393
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1501 User may restore everything (Restore) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1502 User may retire everything (Retire) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1503 User may view everything (View) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1504 User may access the web interface (Web Access) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1505 User may manipulate user Roles through the web (Web Roles) |
|
6393
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1506 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
|
1507 Role "anonymous": |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1508 User may access the web interface (Web Access) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1509 User is allowed to access file (View for "file" only) |
|
6393
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1510 User is allowed to access issue (View for "issue" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1511 User is allowed to access keyword (View for "keyword" only) |
|
6393
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1512 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
|
1513 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
|
1514 User is allowed to access status (View for "status" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1515 User is allowed to register new user (Register for "user" only) |
|
6393
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1516 (Search for "user" only) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1517 Role "user": |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1518 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
|
1519 User may access the rest interface (Rest Access) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1520 User may access the web interface (Web Access) |
|
6393
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1521 User may access the xmlrpc interface (Xmlrpc Access) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1522 User is allowed to create file (Create for "file" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1523 User is allowed to edit file (Edit for "file" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1524 User is allowed to access file (View for "file" only) |
|
6393
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1525 User is allowed to create issue (Create for "issue" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1526 User is allowed to edit issue (Edit for "issue" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1527 User is allowed to access issue (View for "issue" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1528 User is allowed to create keyword (Create for "keyword" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1529 User is allowed to edit keyword (Edit for "keyword" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1530 User is allowed to access keyword (View for "keyword" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1531 User is allowed to create msg (Create for "msg" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1532 User is allowed to edit msg (Edit for "msg" only) |
|
6393
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1533 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
|
1534 User is allowed to access priority (View for "priority" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1535 User is allowed to create queries (Create for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1536 User is allowed to edit their queries (Edit for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1537 User is allowed to restore their queries (Restore for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1538 User is allowed to retire their queries (Retire for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1539 (Search for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1540 User is allowed to view their own and public queries (View for "query" only) |
|
6393
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1541 User is allowed to access status (View for "status" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1542 User is allowed to edit their own user details (Edit for "user": ('username', 'password', 'address', 'realname', 'phone', 'organisation', 'alternate_addresses', 'queries', 'timezone') only) |
|
6393
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1543 (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
|
1544 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
|
1545 """ |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1546 print(out.getvalue()) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1547 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1548 self.assertEqual(result, out.getvalue()) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1549 self.assertEqual(ret, 0) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1550 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1551 def testSecurityInvalidAttribute(self): |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1552 ''' Test with an invalid attribute. |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1553 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
|
1554 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
|
1555 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
|
1556 ''' |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1557 self.maxDiff = None # we want full diff |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1558 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1559 self.install_init() |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1560 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1561 # edit in an invalid attribute/property |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1562 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
|
1563 d = f.readlines() |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1564 f.seek(0) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1565 for i in d: |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1566 if "organisation" in i: |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1567 i = i.replace("'id', 'organisation'","'id', 'organization'") |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1568 f.write(i) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1569 f.truncate() |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1570 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1571 self.admin=AdminTool() |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1572 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1573 with captured_output() as (out, err): |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1574 sys.argv=['main', '-i', self.dirname, 'security' ] |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1575 ret = self.admin.main() |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1576 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1577 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
|
1578 New Email users get the Role "User" |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1579 Role "admin": |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1580 User may create everything (Create) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1581 User may edit everything (Edit) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1582 User may use the email interface (Email Access) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1583 User may access the rest interface (Rest Access) |
|
6393
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1584 User may restore everything (Restore) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1585 User may retire everything (Retire) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1586 User may view everything (View) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1587 User may access the web interface (Web Access) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1588 User may manipulate user Roles through the web (Web Roles) |
|
6393
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1589 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
|
1590 Role "anonymous": |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1591 User may access the web interface (Web Access) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1592 User is allowed to access file (View for "file" only) |
|
6393
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1593 User is allowed to access issue (View for "issue" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1594 User is allowed to access keyword (View for "keyword" only) |
|
6393
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1595 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
|
1596 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
|
1597 User is allowed to access status (View for "status" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1598 User is allowed to register new user (Register for "user" only) |
|
6393
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1599 (Search for "user" only) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1600 Role "user": |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1601 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
|
1602 User may access the rest interface (Rest Access) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1603 User may access the web interface (Web Access) |
|
6393
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1604 User may access the xmlrpc interface (Xmlrpc Access) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1605 User is allowed to create file (Create for "file" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1606 User is allowed to edit file (Edit for "file" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1607 User is allowed to access file (View for "file" only) |
|
6393
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1608 User is allowed to create issue (Create for "issue" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1609 User is allowed to edit issue (Edit for "issue" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1610 User is allowed to access issue (View for "issue" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1611 User is allowed to create keyword (Create for "keyword" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1612 User is allowed to edit keyword (Edit for "keyword" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1613 User is allowed to access keyword (View for "keyword" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1614 User is allowed to create msg (Create for "msg" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1615 User is allowed to edit msg (Edit for "msg" only) |
|
6393
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1616 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
|
1617 User is allowed to access priority (View for "priority" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1618 User is allowed to create queries (Create for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1619 User is allowed to edit their queries (Edit for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1620 User is allowed to restore their queries (Restore for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1621 User is allowed to retire their queries (Retire for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1622 (Search for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1623 User is allowed to view their own and public queries (View for "query" only) |
|
6393
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1624 User is allowed to access status (View for "status" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1625 User is allowed to edit their own user details (Edit for "user": ('username', 'password', 'address', 'realname', 'phone', 'organisation', 'alternate_addresses', 'queries', 'timezone') only) |
|
6393
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1626 (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
|
1627 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1628 **Invalid properties for user: ['organization'] |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1629 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1630 """ |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1631 print(out.getvalue()) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1632 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1633 self.assertEqual(result, out.getvalue()) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1634 self.assertEqual(ret, 1) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1635 |
|
6181
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1636 def testSet(self): |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1637 ''' 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
|
1638 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
|
1639 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
|
1640 ''' |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1641 self.install_init() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1642 self.admin=AdminTool() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1643 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1644 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
|
1645 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
|
1646 '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
|
1647 ret = self.admin.main() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1648 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1649 out = out.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1650 print(out) |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1651 self.assertEqual(out, '1') |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1652 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1653 self.admin=AdminTool() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1654 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
|
1655 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
|
1656 '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
|
1657 ret = self.admin.main() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1658 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1659 out = out.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1660 print(out) |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1661 self.assertEqual(out, '2') |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1662 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1663 self.admin=AdminTool() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1664 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
|
1665 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
|
1666 ret = self.admin.main() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1667 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1668 out = out.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1669 err = err.getvalue().strip() |
|
6332
6a6b4651be1f
Use server-side cursor for postgres in some cases
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6251
diff
changeset
|
1670 self.assertEqual(out, '') |
|
6a6b4651be1f
Use server-side cursor for postgres in some cases
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6251
diff
changeset
|
1671 self.assertEqual(err, '') |
|
6181
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1672 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1673 self.admin=AdminTool() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1674 with captured_output() as (out, err): |
| 6199 | 1675 sys.argv=['main', '-i', self.dirname, 'set', 'issue2', |
| 1676 'tile="new title"'] | |
|
6181
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1677 ret = self.admin.main() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1678 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1679 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
|
1680 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1681 out = out.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1682 err = err.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1683 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
|
1684 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
|
1685 |
| 6199 | 1686 self.admin=AdminTool() |
| 1687 with captured_output() as (out, err): | |
| 1688 sys.argv=['main', '-i', self.dirname, 'set', 'issue2'] | |
| 1689 ret = self.admin.main() | |
| 1690 | |
| 1691 expected_err = "Error: Not enough arguments supplied" | |
| 1692 | |
| 1693 out = out.getvalue().strip() | |
| 1694 err = err.getvalue().strip() | |
| 1695 self.assertEqual(out.index(expected_err), 0) | |
| 1696 self.assertEqual(len(err), 0) | |
| 1697 | |
| 1698 | |
| 1699 self.admin=AdminTool() | |
| 1700 with captured_output() as (out, err): | |
| 1701 sys.argv=['main', '-i', self.dirname, 'set', | |
| 1702 'issue2,issue1,issue', "status=1" ] | |
| 1703 ret = self.admin.main() | |
| 1704 | |
| 1705 expected_err = 'Error: "issue" not a node designator' | |
| 1706 | |
| 1707 out = out.getvalue().strip() | |
| 1708 err = err.getvalue().strip() | |
| 1709 self.assertEqual(out.index(expected_err), 0) | |
| 1710 self.assertEqual(len(err), 0) | |
| 1711 | |
| 1712 self.admin=AdminTool() | |
| 1713 with captured_output() as (out, err): | |
| 1714 sys.argv=['main', '-i', self.dirname, 'set', | |
| 1715 'issue2,issue1,user2', "status=1" ] | |
| 1716 ret = self.admin.main() | |
| 1717 | |
| 1718 expected_err = "Error: 'status' is not a property of user" | |
| 1719 | |
| 1720 out = out.getvalue().strip() | |
| 1721 err = err.getvalue().strip() | |
| 1722 print(out) | |
| 1723 print(expected_err) | |
| 1724 print(err) | |
| 1725 self.assertEqual(out.index(expected_err), 0) | |
| 1726 self.assertEqual(len(err), 0) | |
| 1727 | |
| 1728 self.admin=AdminTool() | |
| 1729 with captured_output() as (out, err): | |
| 1730 sys.argv=['main', '-i', self.dirname, 'set', | |
| 1731 'issue2,issue1,issue1000', "status=1" ] | |
| 1732 ret = self.admin.main() | |
| 1733 | |
| 1734 expected_err = 'Error: no such issue 1000' | |
| 1735 | |
| 1736 out = out.getvalue().strip() | |
| 1737 err = err.getvalue().strip() | |
| 1738 self.assertEqual(out.index(expected_err), 0) | |
| 1739 self.assertEqual(len(err), 0) | |
| 1740 | |
| 1741 def testSetOnClass(self): | |
| 1742 ''' Note the tests will fail if you run this under pdb. | |
| 1743 the context managers capture the pdb prompts and this screws | |
| 1744 up the stdout strings with (pdb) prefixed to the line. | |
| 1745 ''' | |
| 1746 self.install_init() | |
| 1747 | |
| 1748 self.admin=AdminTool() | |
| 1749 with captured_output() as (out, err): | |
| 1750 sys.argv=['main', '-i', self.dirname, 'create', 'issue', | |
| 1751 'title="foo bar"', 'assignedto=admin' ] | |
| 1752 ret = self.admin.main() | |
| 1753 | |
| 1754 out = out.getvalue().strip() | |
| 1755 print(out) | |
| 1756 self.assertEqual(out, '1') | |
| 1757 | |
| 1758 self.admin=AdminTool() | |
| 1759 with captured_output() as (out, err): | |
| 1760 sys.argv=['main', '-i', self.dirname, 'create', 'issue', | |
| 1761 'title="bar foo bar"', 'assignedto=anonymous' ] | |
| 1762 ret = self.admin.main() | |
| 1763 | |
| 1764 out = out.getvalue().strip() | |
| 1765 print(out) | |
| 1766 self.assertEqual(out, '2') | |
| 1767 | |
| 1768 # Run this test in a separate test. | |
| 1769 # It can cause a database timeout/resource | |
| 1770 # unavailable error for anydbm when run with other tests. | |
| 1771 # Not sure why. | |
| 1772 # Set assignedto=2 for all issues | |
| 1773 ## verify that issue 1 and 2 are assigned to user1 and user2 | |
| 1774 self.admin=AdminTool() | |
| 1775 with captured_output() as (out, err): | |
| 1776 sys.argv=['main', '-i', self.dirname, 'table', 'issue', | |
| 1777 'assignedto'] | |
| 1778 ret = self.admin.main() | |
| 1779 | |
| 1780 expected = "Assignedto\n1 \n2" | |
| 1781 out = out.getvalue().strip() | |
| 1782 err = err.getvalue().strip() | |
| 1783 self.assertEqual(out, expected) | |
| 1784 self.assertEqual(len(err), 0) | |
| 1785 self.admin=AdminTool() | |
| 1786 # do the set | |
| 1787 with captured_output() as (out, err): | |
| 1788 sys.argv=['main', '-i', self.dirname, 'set', 'issue', | |
| 1789 'assignedto=2'] | |
| 1790 ret = self.admin.main() | |
| 1791 | |
| 1792 expected_err = "" | |
| 1793 | |
| 1794 out = out.getvalue().strip() | |
| 1795 err = err.getvalue().strip() | |
|
6332
6a6b4651be1f
Use server-side cursor for postgres in some cases
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6251
diff
changeset
|
1796 self.assertEqual(out, '') |
|
6a6b4651be1f
Use server-side cursor for postgres in some cases
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6251
diff
changeset
|
1797 self.assertEqual(err, '') |
| 6199 | 1798 |
| 1799 ## verify that issue 1 and 2 are assigned to user2 and user2 | |
| 1800 self.admin=AdminTool() | |
| 1801 with captured_output() as (out, err): | |
| 1802 sys.argv=['main', '-i', self.dirname, 'table', 'issue', | |
| 1803 'assignedto'] | |
| 1804 ret = self.admin.main() | |
| 1805 | |
| 1806 expected = "Assignedto\n2 \n2" | |
| 1807 out = out.getvalue().strip() | |
| 1808 err = err.getvalue().strip() | |
| 1809 self.assertEqual(out, expected) | |
| 1810 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
|
1811 |
|
6176
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
1812 def testSpecification(self): |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
1813 ''' 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
|
1814 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
|
1815 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
|
1816 ''' |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
1817 self.install_init() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
1818 self.admin=AdminTool() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
1819 |
|
6178
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1820 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
|
1821 'alternate_addresses: <roundup.hyperdb.String>', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1822 'realname: <roundup.hyperdb.String>', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1823 'roles: <roundup.hyperdb.String>', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1824 'organisation: <roundup.hyperdb.String>', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1825 'queries: <roundup.hyperdb.Multilink to "query">', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1826 'phone: <roundup.hyperdb.String>', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1827 'address: <roundup.hyperdb.String>', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1828 'timezone: <roundup.hyperdb.String>', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1829 'password: <roundup.hyperdb.Password>', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1830 ] |
|
7543
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1831 |
|
6178
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1832 |
|
6176
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
1833 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
|
1834 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
|
1835 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
|
1836 |
|
6178
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1837 outlist = out.getvalue().strip().split("\n") |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1838 print(outlist) |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
1839 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
|
1840 |
|
7543
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1841 # ----- |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1842 self.install_init() |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1843 self.admin=AdminTool() |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1844 |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1845 with captured_output() as (out, err): |
|
7546
534f8bdb8f94
Add -P pragma=value command line option to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7543
diff
changeset
|
1846 sys.argv=['main', '-i', self.dirname, '-P', |
|
534f8bdb8f94
Add -P pragma=value command line option to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7543
diff
changeset
|
1847 'display_protected=1', 'specification', 'user'] |
|
7543
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1848 ret = self.admin.main() |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1849 |
|
7546
534f8bdb8f94
Add -P pragma=value command line option to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7543
diff
changeset
|
1850 outlist = out.getvalue().strip().split('\n') |
|
7543
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1851 |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1852 protected = [ 'id: <roundup.hyperdb.String>', |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1853 'creation: <roundup.hyperdb.Date>', |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1854 'activity: <roundup.hyperdb.Date>', |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1855 'creator: <roundup.hyperdb.Link to "user">', |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1856 'actor: <roundup.hyperdb.Link to "user">'] |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1857 print(outlist) |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1858 self.assertEqual(sorted(outlist), sorted(spec + protected)) |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1859 |
|
6430
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
1860 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
|
1861 ''' 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
|
1862 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
|
1863 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
|
1864 ''' |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
1865 # 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
|
1866 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
|
1867 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
|
1868 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
|
1869 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
|
1870 '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
|
1871 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
|
1872 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
1873 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
|
1874 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
|
1875 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
|
1876 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
1877 # 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
|
1878 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
|
1879 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
|
1880 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
|
1881 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
|
1882 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
|
1883 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
|
1884 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
|
1885 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
1886 # 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
|
1887 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
|
1888 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
|
1889 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
|
1890 '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
|
1891 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
|
1892 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
1893 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
|
1894 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
|
1895 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
|
1896 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
1897 # 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
|
1898 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
|
1899 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
|
1900 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
|
1901 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
|
1902 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
|
1903 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
|
1904 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
|
1905 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
1906 # 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
|
1907 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
|
1908 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
|
1909 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
|
1910 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
|
1911 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
|
1912 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
|
1913 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
|
1914 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
|
1915 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
1916 # 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
|
1917 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
|
1918 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
|
1919 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
|
1920 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
|
1921 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
|
1922 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
|
1923 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
|
1924 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
1925 # 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
|
1926 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
|
1927 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
|
1928 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
|
1929 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
|
1930 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
|
1931 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
|
1932 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
|
1933 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
1934 # 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
|
1935 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
|
1936 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
|
1937 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
|
1938 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
|
1939 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
|
1940 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
|
1941 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
|
1942 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
|
1943 |
|
7547
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1944 # test show_retired pragma three cases: |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1945 # no - no retired items |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1946 # only - only retired items |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1947 # both - all items |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1948 |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1949 # verify that user4 only is listed |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1950 self.admin=AdminTool() |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1951 with captured_output() as (out, err): |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1952 sys.argv=['main', '-i', self.dirname, '-P', |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1953 'show_retired=only', 'list', 'user'] |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1954 ret = self.admin.main() |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1955 out = out.getvalue().strip() |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1956 print(out) |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1957 expected="4: user1" |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1958 self.assertEqual(out, expected) |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1959 |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1960 # verify that all users are shown |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1961 self.admin=AdminTool() |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1962 with captured_output() as (out, err): |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1963 sys.argv=['main', '-i', self.dirname, '-P', |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1964 'show_retired=both', 'list', 'user'] |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1965 ret = self.admin.main() |
|
7548
793f4b63c538
Fix test where postgres returned items in different order
John Rouillard <rouilj@ieee.org>
parents:
7547
diff
changeset
|
1966 out_list = sorted(out.getvalue().strip().split("\n")) |
|
7547
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1967 print(out) |
|
7548
793f4b63c538
Fix test where postgres returned items in different order
John Rouillard <rouilj@ieee.org>
parents:
7547
diff
changeset
|
1968 expected_list=sorted("1: admin\n 2: anonymous\n 3: user1\n 4: user1".split("\n")) |
|
793f4b63c538
Fix test where postgres returned items in different order
John Rouillard <rouilj@ieee.org>
parents:
7547
diff
changeset
|
1969 self.assertEqual(out_list, expected_list) |
|
7547
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1970 |
|
7549
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
1971 # verify that active users are shown |
|
7547
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1972 self.admin=AdminTool() |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1973 with captured_output() as (out, err): |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1974 sys.argv=['main', '-i', self.dirname, '-P', |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1975 'show_retired=no', 'list', 'user'] |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1976 ret = self.admin.main() |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1977 out = out.getvalue().strip() |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1978 print(out) |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1979 expected="1: admin\n 2: anonymous\n 3: user1" |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
1980 self.assertEqual(out, expected) |
|
6430
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
1981 |
|
7549
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
1982 # test display headers for retired/active |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
1983 self.admin=AdminTool() |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
1984 with captured_output() as (out, err): |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
1985 sys.argv=['main', '-i', self.dirname, '-P', |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
1986 'display_header=yes', 'display', 'user3,user4'] |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
1987 ret = self.admin.main() |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
1988 out = out.getvalue().strip() |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
1989 print(out) |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
1990 self.assertIn("[user3 (active)]\n", out) |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
1991 self.assertIn( "[user4 (retired)]\n", out) |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
1992 |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
1993 # test that there are no headers |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
1994 self.admin=AdminTool() |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
1995 with captured_output() as (out, err): |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
1996 sys.argv=['main', '-i', self.dirname, 'display', 'user3,user4'] |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
1997 ret = self.admin.main() |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
1998 out = out.getvalue().strip() |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
1999 print(out) |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
2000 self.assertNotIn("user3", out) |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
2001 self.assertNotIn("user4", out) |
|
6430
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
2002 |
| 6199 | 2003 def testTable(self): |
| 2004 ''' Note the tests will fail if you run this under pdb. | |
| 2005 the context managers capture the pdb prompts and this screws | |
| 2006 up the stdout strings with (pdb) prefixed to the line. | |
| 2007 ''' | |
| 2008 self.install_init() | |
| 2009 self.admin=AdminTool() | |
| 2010 | |
| 2011 with captured_output() as (out, err): | |
| 2012 sys.argv=['main', '-i', self.dirname, 'table' ] | |
| 2013 ret = self.admin.main() | |
| 2014 | |
| 2015 expected = 'Error: Not enough arguments supplied' | |
| 2016 | |
| 2017 out = out.getvalue().strip() | |
| 2018 print(out) | |
| 2019 print(expected) | |
| 2020 self.assertTrue(expected in out) | |
| 2021 #### | |
| 2022 | |
| 2023 self.admin=AdminTool() | |
| 2024 | |
| 2025 with captured_output() as (out, err): | |
| 2026 sys.argv=['main', '-i', self.dirname, 'table', | |
| 2027 'id,realname,username' ] | |
| 2028 ret = self.admin.main() | |
| 2029 | |
| 2030 expected = 'Error: no such class "id,realname,username"' | |
| 2031 | |
| 2032 out = out.getvalue().strip() | |
| 2033 print(out) | |
| 2034 print(expected) | |
| 2035 self.assertTrue(expected in out) | |
| 2036 | |
| 2037 #### | |
| 2038 self.admin=AdminTool() | |
| 2039 | |
| 2040 with captured_output() as (out, err): | |
| 2041 sys.argv=['main', '-i', self.dirname, 'table', 'user', | |
| 2042 'id,realname,username:4:3' ] | |
| 2043 ret = self.admin.main() | |
| 2044 expected = 'Error: "username:4:3" not name:width' | |
| 2045 | |
| 2046 out = out.getvalue().strip() | |
| 2047 print(out) | |
| 2048 print(expected) | |
| 2049 self.assertTrue(expected in out) | |
| 2050 | |
| 2051 #### | |
| 2052 self.admin=AdminTool() | |
| 2053 | |
| 2054 with captured_output() as (out, err): | |
| 2055 sys.argv=['main', '-i', self.dirname, 'table', 'user', | |
| 2056 'id,realname,title:4' ] | |
| 2057 ret = self.admin.main() | |
| 2058 expected = 'Error: user has no property "title"' | |
| 2059 | |
| 2060 out = out.getvalue().strip() | |
| 2061 print(out) | |
| 2062 print(expected) | |
| 2063 self.assertTrue(expected in out) | |
| 2064 | |
| 2065 #### | |
| 2066 self.admin=AdminTool() | |
| 2067 | |
| 2068 with captured_output() as (out, err): | |
| 2069 sys.argv=['main', '-i', self.dirname, 'table', 'user', | |
| 2070 'id,realname,username:' ] | |
| 2071 ret = self.admin.main() | |
| 2072 | |
| 2073 # note whitespace matters. trailing spaces on lines 1 and 2 | |
| 2074 expected = """Id Realname Username | |
| 2075 1 None admin | |
| 2076 2 None anonymou""" | |
| 2077 | |
| 2078 out = out.getvalue().strip() | |
| 2079 print(out) | |
| 2080 print(expected) | |
| 2081 self.assertEqual(out, expected) | |
| 2082 | |
| 2083 #### | |
| 2084 self.admin=AdminTool() | |
| 2085 | |
| 2086 with captured_output() as (out, err): | |
| 2087 sys.argv=['main', '-i', self.dirname, 'table', 'user', | |
| 2088 'id,realname,username' ] | |
| 2089 ret = self.admin.main() | |
| 2090 | |
| 2091 # note whitespace matters. trailing spaces on lines 1 and 2 | |
| 2092 expected = """Id Realname Username | |
| 2093 1 None admin | |
| 2094 2 None anonymous""" | |
| 2095 | |
| 2096 out = out.getvalue().strip() | |
| 2097 print(out) | |
| 2098 print(expected) | |
| 2099 self.assertEqual(out, expected) | |
| 2100 | |
| 2101 #### | |
| 2102 self.admin=AdminTool() | |
| 2103 | |
| 2104 with captured_output() as (out, err): | |
| 2105 sys.argv=['main', '-i', self.dirname, 'table', 'user', | |
| 2106 'id:4,realname:2,username:3' ] | |
| 2107 ret = self.admin.main() | |
| 2108 | |
| 2109 # note whitespace matters. trailing spaces on lines 1 and 2 | |
| 2110 expected = """Id Realname Username | |
| 2111 1 No adm | |
| 2112 2 No ano""" | |
| 2113 | |
| 2114 out = out.getvalue().strip() | |
| 2115 print(out) | |
| 2116 print(expected) | |
| 2117 self.assertEqual(out, expected) | |
| 2118 | |
|
6957
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2119 def testTemplates(self): |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2120 |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2121 self.install_init() |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2122 self.admin=AdminTool() |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2123 |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2124 with captured_output() as (out, err): |
|
6958
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
2125 # 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
|
2126 # 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
|
2127 sys.argv=['main', '-i', "zZzZ", 'templates' ] |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2128 ret = self.admin.main() |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2129 |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2130 out = out.getvalue().strip() |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2131 |
|
6958
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
2132 # 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
|
2133 for tracker in ['Name: classic\nPath:', |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2134 'Name: devel\nPath:', |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2135 'Name: jinja2\nPath:', |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2136 'Name: minimal\nPath:', |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2137 'Name: responsive\nPath:']: |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2138 self.assertIn(tracker, out) |
|
5713
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2139 |
|
6958
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
2140 with captured_output() as (out, err): |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
2141 # 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
|
2142 # directory to cause error if that changes |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
2143 sys.argv=['main', '-i', "zZzZ", 'templates', 'trace_search' ] |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
2144 ret = self.admin.main() |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
2145 |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
2146 out = out.getvalue().strip() |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
2147 |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
2148 expected = "/*\n" |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
2149 self.assertIn(expected, out) |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
2150 |
|
5713
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2151 class anydbmAdminTest(AdminTest, unittest.TestCase): |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2152 backend = 'anydbm' |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2153 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2154 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2155 @skip_mysql |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2156 class mysqlAdminTest(AdminTest, unittest.TestCase): |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2157 backend = 'mysql' |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2158 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2159 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2160 class sqliteAdminTest(AdminTest, unittest.TestCase): |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2161 backend = 'sqlite' |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2162 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2163 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2164 @skip_postgresql |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2165 class postgresqlAdminTest(AdminTest, unittest.TestCase): |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2166 backend = 'postgresql' |
