Mercurial > p > roundup > code
annotate test/test_admin.py @ 8538:f676eda10c20
build(deps): bump codecov/codecov-action from 5.5.2 to 5.5.3 #85
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 22 Mar 2026 22:39:40 -0400 |
| parents | 254f70dfc585 |
| children | 9c3ec0a5c7fc |
| 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 |
|
8439
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
8 import difflib |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
9 import errno |
|
7204
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
10 import fileinput |
|
8439
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
11 import io |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
12 import os |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
13 import platform |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
14 import pytest |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
15 import re |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
16 import shutil |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
17 import sys |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
18 import unittest |
|
5713
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
19 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
20 from roundup.admin import AdminTool |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
21 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
22 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
|
23 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
|
24 |
|
6178
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
25 #from roundup import instance |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
26 |
|
6176
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
27 # 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
|
28 # lightly modified |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
29 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
|
30 _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
|
31 if _py3: |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
32 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
|
33 else: |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
34 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
|
35 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
36 @contextmanager |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
37 def captured_output(): |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
38 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
|
39 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
|
40 try: |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
41 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
|
42 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
|
43 finally: |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
44 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
|
45 |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
46 def normalize_file(filename, skiplines = [ None ]): |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
47 # 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
|
48 |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
49 with open(filename, "r+") as f: |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
50 d = f.readlines() |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
51 f.seek(0) |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
52 for i in d: |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
53 for skip in skiplines: |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
54 if skip not in i: |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
55 f.write(i) |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
56 f.truncate() |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
57 |
|
7204
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
58 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
|
59 """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
|
60 will be replaced by replacement""" |
|
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 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
|
63 print(line.replace(original, replacement)) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
64 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
65 fileinput.close() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
66 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
67 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
|
68 """search for regexp in file. |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
69 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
|
70 """ |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
71 with open(filename) as f: |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
72 contents = f.read() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
73 |
|
7585
227aca44fea5
test: fix failure under cygwin python caused by line endings
John Rouillard <rouilj@ieee.org>
parents:
7582
diff
changeset
|
74 try: |
|
227aca44fea5
test: fix failure under cygwin python caused by line endings
John Rouillard <rouilj@ieee.org>
parents:
7582
diff
changeset
|
75 # 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
|
76 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
|
77 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
|
78 except ValueError: |
|
227aca44fea5
test: fix failure under cygwin python caused by line endings
John Rouillard <rouilj@ieee.org>
parents:
7582
diff
changeset
|
79 pass |
|
227aca44fea5
test: fix failure under cygwin python caused by line endings
John Rouillard <rouilj@ieee.org>
parents:
7582
diff
changeset
|
80 |
|
7204
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
81 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
|
82 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
83 if not m: return False |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
84 |
|
7205
1a3d4703c7d6
Fix for python2. m[0] -> m.group(0)
John Rouillard <rouilj@ieee.org>
parents:
7204
diff
changeset
|
85 return m.group(0) |
|
7204
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
86 |
|
5713
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
87 class AdminTest(object): |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
88 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
89 backend = None |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
90 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
91 def setUp(self): |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
92 self.dirname = '_test_admin' |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
93 |
|
8439
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
94 @pytest.fixture(autouse=True) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
95 def inject_fixtures(self, monkeypatch): |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
96 self._monkeypatch = monkeypatch |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
97 |
|
5713
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
98 def tearDown(self): |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
99 try: |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
100 shutil.rmtree(self.dirname) |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
101 except OSError as error: |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
102 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
|
103 |
|
6176
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
104 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
|
105 settings="mail_domain=example.com," + |
|
6177
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
106 "mail_host=localhost," + |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
107 "tracker_web=http://test/," + |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
108 "rdbms_name=rounduptest," + |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
109 "rdbms_user=rounduptest," + |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
110 "rdbms_password=rounduptest," + |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
111 "rdbms_template=template0" |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
112 ): |
|
6176
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
113 ''' 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
|
114 ''' |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
115 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
116 admin=AdminTool() |
|
6178
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
117 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
|
118 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
119 # 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
|
120 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
|
121 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
|
122 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
|
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 # nuke any existing database (mysql/postgreql) |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
127 # 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
|
128 #tracker = instance.open(self.dirname) |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
129 #if tracker.exists(): |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
130 # tracker.nuke() |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
131 |
|
6176
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
132 # 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
|
133 # 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
|
134 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
|
135 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
|
136 ret = admin.main() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
137 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
|
138 |
|
6178
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
139 |
|
7182
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
140 def testBasicInteractive(self): |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
141 # 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
|
142 inputs = iter(["'quit", "quit"]) |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
143 |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
144 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
|
145 |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
146 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
|
147 |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
148 self.install_init() |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
149 self.admin=AdminTool() |
|
7803
2746337ded4c
fix: disable history file changes when testing
John Rouillard <rouilj@ieee.org>
parents:
7802
diff
changeset
|
150 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
|
151 # 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
|
152 # 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
|
153 # 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
|
154 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
|
155 |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
156 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
|
157 ret = self.admin.main() |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
158 |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
159 out = out.getvalue().strip() |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
160 |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
161 print(ret) |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
162 self.assertTrue(ret == 0) |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
163 expected = 'ready for input.\nType "help" for help.' |
|
8439
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
164 # back up by 30 to make sure 'ready for input' in slice. |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
165 self.assertIn(expected, |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
166 "\n".join(out.split('\n')[-3:-1])) |
|
7182
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
167 |
|
8435
1a93dc58f975
feat: add 'q' as alias to quit to exit interactive roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8244
diff
changeset
|
168 inputs = iter(["list user", "q"]) |
|
7182
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
169 |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
170 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
|
171 |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
172 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
|
173 ret = self.admin.main() |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
174 |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
175 out = out.getvalue().strip() |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
176 |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
177 print(ret) |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
178 self.assertTrue(ret == 0) |
|
8439
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
179 expected = ' 1: admin\n 2: anonymous' |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
180 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
181 self.assertEqual(expected, |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
182 "\n".join(out.split('\n')[-2:])) |
|
7182
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
183 |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
184 |
|
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
185 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
|
186 |
|
8440
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
187 # test EOF exit |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
188 inputs = ["help"] |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
189 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
190 self._monkeypatch.setattr( |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
191 'sys.stdin', |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
192 io.StringIO("\n".join(inputs))) |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
193 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
194 # preserve directory self.install_init() |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
195 self.admin=AdminTool() |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
196 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
197 # disable all features |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
198 self.admin.settings['history_features'] = 7 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
199 sys.argv=['main', '-i', self.dirname] |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
200 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
201 with captured_output() as (out, err): |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
202 ret = self.admin.main() |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
203 out = out.getvalue().strip().split('\n') |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
204 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
205 print(ret) |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
206 self.assertTrue(ret == 0) |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
207 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
208 # 4 includes 2 commands in saved history |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
209 expected = 'roundup> exit...' |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
210 self.assertIn(expected, out) |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
211 |
|
6181
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
212 def testGet(self): |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
213 ''' 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
|
214 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
|
215 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
|
216 ''' |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
217 self.install_init() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
218 self.admin=AdminTool() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
219 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
220 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
|
221 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
|
222 '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
|
223 ret = self.admin.main() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
224 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
225 out = out.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
226 print(out) |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
227 self.assertEqual(out, '1') |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
228 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
229 self.admin=AdminTool() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
230 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
|
231 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
|
232 '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
|
233 'superseder=1'] |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
234 ret = self.admin.main() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
235 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
236 self.assertEqual(ret, 0) |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
237 out = out.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
238 print(out) |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
239 self.assertEqual(out, '2') |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
240 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
241 self.admin=AdminTool() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
242 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
|
243 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
|
244 '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
|
245 'superseder=1,2'] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
246 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
247 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
248 self.assertEqual(ret, 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
249 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
250 print(out) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
251 self.assertEqual(out, '3') |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
252 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
253 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
254 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
|
255 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
|
256 'issue2' ] |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
257 ret = self.admin.main() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
258 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
259 self.assertEqual(ret, 0) |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
260 out = out.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
261 err = err.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
262 self.assertEqual(out, '2') |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
263 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
|
264 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
265 self.admin=AdminTool() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
266 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
|
267 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
|
268 'get', 'assignedto', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
269 'issue2' ] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
270 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
271 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
272 self.assertEqual(ret, 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
273 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
274 err = err.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
275 self.assertEqual(out, 'user2') |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
276 self.assertEqual(len(err), 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
277 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
278 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
279 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
|
280 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
|
281 'get', 'assignedto', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
282 'issue2' ] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
283 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
284 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
285 self.assertEqual(ret, 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
286 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
287 err = err.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
288 self.assertEqual(out, 'user2') |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
289 self.assertEqual(len(err), 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
290 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
291 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
292 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
|
293 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
|
294 'issue2' ] |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
295 ret = self.admin.main() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
296 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
297 self.assertEqual(ret, 0) |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
298 out = out.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
299 err = err.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
300 self.assertEqual(out, "['1']") |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
301 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
|
302 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
303 self.admin=AdminTool() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
304 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
|
305 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
|
306 'issue3' ] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
307 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
308 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
309 self.assertEqual(ret, 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
310 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
311 err = err.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
312 self.assertEqual(out, "['1', '2']") |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
313 self.assertEqual(len(err), 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
314 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
315 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
316 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
|
317 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
|
318 'get', 'superseder', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
319 'issue3' ] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
320 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
321 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
322 self.assertEqual(ret, 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
323 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
324 err = err.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
325 self.assertEqual(out, "issue1\nissue2") |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
326 self.assertEqual(len(err), 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
327 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
328 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
329 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
|
330 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
|
331 'get', 'superseder', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
332 'issue3' ] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
333 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
334 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
335 self.assertEqual(ret, 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
336 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
337 err = err.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
338 self.assertEqual(out, "issue1,issue2") |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
339 self.assertEqual(len(err), 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
340 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
341 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
342 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
|
343 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
|
344 'get', 'title', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
345 'issue3' ] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
346 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
347 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
348 self.assertEqual(ret, 1) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
349 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
350 err = err.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
351 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
|
352 self.assertEqual(len(err), 0) |
|
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 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
355 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
|
356 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
|
357 ret = self.admin.main() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
358 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
359 self.assertEqual(ret, 0) |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
360 out = out.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
361 err = err.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
362 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
|
363 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
|
364 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
365 self.admin=AdminTool() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
366 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
|
367 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
|
368 ret = self.admin.main() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
369 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
370 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
|
371 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
372 self.assertEqual(ret, 1) |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
373 out = out.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
374 err = err.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
375 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
|
376 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
|
377 |
| 6199 | 378 self.admin=AdminTool() |
| 379 with captured_output() as (out, err): | |
| 380 sys.argv=['main', '-i', self.dirname, 'get', 'title', 'issue'] | |
| 381 ret = self.admin.main() | |
| 382 | |
| 383 expected_err = 'Error: "issue" not a node designator' | |
| 384 | |
| 385 self.assertEqual(ret, 1) | |
| 386 out = out.getvalue().strip() | |
| 387 err = err.getvalue().strip() | |
| 388 self.assertEqual(out.index(expected_err), 0) | |
| 389 self.assertEqual(len(err), 0) | |
| 390 | |
|
7752
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
391 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
392 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
|
393 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
|
394 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
395 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
396 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
|
397 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
398 self.assertEqual(ret, 1) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
399 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
400 err = err.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
401 print(out) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
402 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
|
403 self.assertEqual(len(err), 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
404 |
|
5713
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
405 def testInit(self): |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
406 self.admin=AdminTool() |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
407 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
|
408 ret = self.admin.main() |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
409 print(ret) |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
410 self.assertTrue(ret == 0) |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
411 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
|
412 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
|
413 |
|
7883
23b7669b2f48
test: fix path issues posix vs windows in admin functions.
John Rouillard <rouilj@ieee.org>
parents:
7870
diff
changeset
|
414 nopath= '/tmp/noSuchDirectory/nodir' |
|
23b7669b2f48
test: fix path issues posix vs windows in admin functions.
John Rouillard <rouilj@ieee.org>
parents:
7870
diff
changeset
|
415 norealpath = os.path.realpath(nopath + "/..") |
|
7392
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
416 self.admin=AdminTool() |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
417 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
|
418 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
|
419 ret = self.admin.main() |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
420 |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
421 out = out.getvalue().strip() |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
422 print(ret) |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
423 print(out) |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
424 self.assertEqual(ret, 1) |
|
bd6523c84a95
Fix test failure caused by making genconfig trackerless
John Rouillard <rouilj@ieee.org>
parents:
7254
diff
changeset
|
425 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
|
426 '"%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
|
427 |
|
5762
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
428 def testInitWithConfig_ini(self): |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
429 from roundup.configuration import CoreConfig |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
430 self.admin=AdminTool() |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
431 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
|
432 # create a config_ini.ini file in classic template |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
433 templates=self.admin.listTemplates() |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
434 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
|
435 config_ini_path = templates['classic']['path'] + '/config_ini.ini' |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
436 config_ini_file = open(config_ini_path, "w") |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
437 config_ini_file.write(config_ini_content) |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
438 config_ini_file.close() |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
439 |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
440 try: |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
441 ret = self.admin.main() |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
442 finally: |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
443 try: |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
444 # ignore file not found |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
445 os.remove(config_ini_path) |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
446 except OSError as e: # FileNotFound exception under py3 |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
447 if e.errno == 2: |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
448 pass |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
449 else: |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
450 raise |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
451 |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
452 print(ret) |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
453 self.assertTrue(ret == 0) |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
454 self.assertTrue(os.path.isfile(self.dirname + "/config.ini")) |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
455 self.assertTrue(os.path.isfile(self.dirname + "/schema.py")) |
|
b76be13e027e
issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents:
5713
diff
changeset
|
456 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
|
457 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
|
458 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
|
459 |
|
7752
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
460 def testList(self): |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
461 ''' 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
|
462 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
|
463 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
|
464 ''' |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
465 self.install_init() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
466 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
467 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
468 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
|
469 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
|
470 'username' ] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
471 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
472 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
473 self.assertEqual(ret, 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
474 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
475 print(out) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
476 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
|
477 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
478 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
479 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
480 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
|
481 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
|
482 'list', 'user' ] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
483 ret = self.admin.main() |
|
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 self.assertEqual(ret, 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
486 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
487 print(out) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
488 self.assertEqual(out, '1,2') |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
489 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
490 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
491 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
492 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
|
493 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
|
494 'list', 'user', 'username' ] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
495 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
496 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
497 self.assertEqual(ret, 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
498 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
499 print(out) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
500 self.assertEqual(out, 'admin,anonymous') |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
501 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
502 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
503 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
504 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
|
505 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
|
506 'list', 'user', 'roles' ] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
507 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
508 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
509 self.assertEqual(ret, 0) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
510 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
511 print(out) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
512 self.assertEqual(out, 'Admin,Anonymous') |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
513 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
514 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
515 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
516 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
|
517 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
|
518 'foo' ] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
519 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
520 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
521 self.assertEqual(ret, 1) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
522 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
523 print(out) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
524 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
|
525 '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
|
526 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
527 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
528 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
529 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
530 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
|
531 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
|
532 'list', 'user', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
533 'bar' ] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
534 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
535 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
536 self.assertEqual(ret, 1) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
537 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
538 print(out) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
539 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
|
540 '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
|
541 |
|
6176
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
542 def testFind(self): |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
543 ''' 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
|
544 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
|
545 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
|
546 ''' |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
547 self.admin=AdminTool() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
548 self.install_init() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
549 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
550 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
|
551 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
|
552 '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
|
553 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
|
554 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
555 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
|
556 print(out) |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
557 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
|
558 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
559 self.admin=AdminTool() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
560 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
|
561 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
|
562 '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
|
563 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
|
564 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
565 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
|
566 print(out) |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
567 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
|
568 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
569 self.admin=AdminTool() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
570 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
|
571 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
|
572 'assignedto=1'] |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
573 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
|
574 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
575 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
|
576 print(out) |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
577 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
|
578 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
579 # 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
|
580 self.admin=AdminTool() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
581 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
|
582 ''' 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
|
583 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
|
584 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
585 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
|
586 'assignedto=1,2'] |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
587 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
|
588 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
589 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
|
590 print(out) |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
591 # 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
|
592 # 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
|
593 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
|
594 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
595 # 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
|
596 self.admin=AdminTool() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
597 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
|
598 ''' 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
|
599 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
|
600 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
601 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
|
602 'assignedto=admin,anonymous'] |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
603 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
|
604 |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
605 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
|
606 print(out) |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
607 # 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
|
608 # 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
|
609 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
|
610 |
|
7752
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
611 # 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
|
612 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
613 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
|
614 ''' 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
|
615 either admin or anonymous |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
616 ''' |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
617 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
|
618 'find', 'issue', 'assignedto=admin,anonymous'] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
619 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
620 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
621 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
622 print(out) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
623 self.assertEqual(out, "issue1,issue2") |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
624 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
625 # 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
|
626 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
627 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
|
628 ''' 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
|
629 either admin or anonymous |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
630 ''' |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
631 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
|
632 'find', 'issue', 'assignedto=admin,anonymous'] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
633 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
634 |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
635 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
636 print(out) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
637 self.assertEqual(out, "1:2") |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
638 |
|
6188
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
639 def testGenconfigUpdate(self): |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
640 ''' 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
|
641 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
|
642 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
|
643 ''' |
|
7182
0c6617db0b97
Add testing interactive mode to roundup_admin. remove redundant imports
John Rouillard <rouilj@ieee.org>
parents:
7168
diff
changeset
|
644 import filecmp |
|
6188
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
645 |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
646 self.admin=AdminTool() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
647 self.install_init() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
648 |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
649 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
|
650 sys.argv=['main', '-i', self.dirname, 'genconfig'] |
|
6188
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
651 ret = self.admin.main() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
652 |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
653 out = out.getvalue().strip() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
654 print(out) |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
655 expected = "Not enough arguments supplied" |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
656 self.assertTrue(expected in out) |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
657 |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
658 # Reopen the db closed by previous call |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
659 self.admin=AdminTool() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
660 |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
661 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
|
662 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
|
663 self.dirname + "/config2.ini"] |
|
6188
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
664 ret = self.admin.main() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
665 |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
666 out = out.getvalue().strip() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
667 print(out) |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
668 # FIXME get better successful test later. |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
669 expected = "" |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
670 self.assertTrue(expected in out) |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
671 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
|
672 # 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
|
673 # 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
|
674 # to be customized. |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
675 #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
|
676 # self.dirname + "/config.ini")) |
|
6188
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
677 |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
678 # Reopen the db closed by previous call |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
679 self.admin=AdminTool() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
680 |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
681 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
|
682 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
|
683 self.dirname + "/foo2.ini"] |
|
6188
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
684 ret = self.admin.main() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
685 |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
686 out = out.getvalue().strip() |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
687 print(out) |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
688 # FIXME get better successful test later. |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
689 expected = "" |
|
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
690 self.assertTrue(expected in out) |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
691 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
|
692 |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
693 # 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
|
694 # so filecmp passes. |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
695 normalize_file(self.dirname + "/foo2.ini", |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
696 [ '# Autogenerated at' ]) |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
697 normalize_file(self.dirname + "/config.ini", |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
698 [ '# Autogenerated at' ]) |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
699 |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
700 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
|
701 self.dirname + "/foo2.ini")) |
|
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
702 |
|
7204
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
703 def testUpdateconfigPbkdf2(self): |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
704 ''' 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
|
705 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
|
706 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
|
707 ''' |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
708 import filecmp |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
709 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
710 self.admin=AdminTool() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
711 self.install_init() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
712 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
713 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
|
714 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
|
715 self.dirname + "/config2.ini"] |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
716 ret = self.admin.main() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
717 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
718 out = out.getvalue().strip() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
719 print(out) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
720 self.assertEqual(out, "") |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
721 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
|
722 # 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
|
723 # so filecmp passes. |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
724 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
|
725 [ '# Autogenerated at' ]) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
726 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
|
727 [ '# Autogenerated at' ]) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
728 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
729 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
|
730 self.dirname + "/config2.ini")) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
731 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
732 # 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
|
733 self.admin=AdminTool() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
734 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
735 ### 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
|
736 replace_in_file(self.dirname + "/config.ini", |
|
8244
b4ad03927711
test: fix failing test setup for change in PBKDF2 rounds.
John Rouillard <rouilj@ieee.org>
parents:
8119
diff
changeset
|
737 "= 250000", "= 10000") |
|
b4ad03927711
test: fix failing test setup for change in PBKDF2 rounds.
John Rouillard <rouilj@ieee.org>
parents:
8119
diff
changeset
|
738 |
|
7204
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
739 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
|
740 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
|
741 self.dirname + "/config2.ini"] |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
742 ret = self.admin.main() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
743 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
744 out = out.getvalue().strip() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
745 print(out) |
|
8244
b4ad03927711
test: fix failing test setup for change in PBKDF2 rounds.
John Rouillard <rouilj@ieee.org>
parents:
8119
diff
changeset
|
746 expected = "from old default of 10000 to new default of 250000." |
|
7204
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
747 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
748 self.assertIn(expected, out) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
749 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
|
750 self.assertEqual(find_in_file(self.dirname + "/config2.ini", |
|
8244
b4ad03927711
test: fix failing test setup for change in PBKDF2 rounds.
John Rouillard <rouilj@ieee.org>
parents:
8119
diff
changeset
|
751 "^password_.*= 250000$"), |
|
b4ad03927711
test: fix failing test setup for change in PBKDF2 rounds.
John Rouillard <rouilj@ieee.org>
parents:
8119
diff
changeset
|
752 "password_pbkdf2_default_rounds = 250000") |
|
7204
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
753 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
754 # 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
|
755 self.admin=AdminTool() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
756 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
757 ### 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
|
758 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
|
759 "= 10000", "= 10001") |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
760 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
|
761 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
|
762 self.dirname + "/config2.ini"] |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
763 ret = self.admin.main() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
764 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
765 out = out.getvalue().strip() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
766 print(out) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
767 expected = ("Update 'password_pbkdf2_default_rounds' to a number " |
|
8244
b4ad03927711
test: fix failing test setup for change in PBKDF2 rounds.
John Rouillard <rouilj@ieee.org>
parents:
8119
diff
changeset
|
768 "equal to or larger\n than 250000.") |
|
7204
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
769 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
770 self.assertIn(expected, out) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
771 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
|
772 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
|
773 "^password_.*= 10001$"), |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
774 "password_pbkdf2_default_rounds = 10001") |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
775 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
776 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
777 # 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
|
778 self.admin=AdminTool() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
779 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
780 ### 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
|
781 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
|
782 "= 10001", "= 2000001") |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
783 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
|
784 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
|
785 self.dirname + "/config2.ini"] |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
786 ret = self.admin.main() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
787 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
788 out = out.getvalue().strip() |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
789 print(out) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
790 expected = "" |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
791 |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
792 self.assertEqual(expected, out) |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
793 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
|
794 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
|
795 "^password_.*= 2000001$"), |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
796 "password_pbkdf2_default_rounds = 2000001") |
|
ccb0e566e0be
Add missing space in message; add tests; update .po
John Rouillard <rouilj@ieee.org>
parents:
7182
diff
changeset
|
797 |
|
6188
32ebffbae49a
Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents:
6186
diff
changeset
|
798 |
|
6186
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
799 def testCliParse(self): |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
800 ''' 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
|
801 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
|
802 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
|
803 ''' |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
804 self.admin=AdminTool() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
805 self.install_init() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
806 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
807 # 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
|
808 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
809 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
|
810 ''' 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
|
811 report error. |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
812 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
813 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
|
814 'assignedto=1'] |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
815 ret = self.admin.main() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
816 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
817 out = out.getvalue().strip() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
818 print(out) |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
819 expected="[ '1' ]" |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
820 self.assertTrue(expected, out) |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
821 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
822 # 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
|
823 self.admin=AdminTool() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
824 # test multiple matches |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
825 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
|
826 ''' 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
|
827 report error. |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
828 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
829 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
|
830 'assignedto'] |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
831 ret = self.admin.main() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
832 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
833 out = out.getvalue().strip() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
834 print(out) |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
835 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
|
836 self.assertEqual(expected, out) |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
837 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
838 # 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
|
839 self.admin=AdminTool() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
840 # 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
|
841 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
|
842 ''' 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
|
843 report error. |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
844 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
845 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
|
846 'assignedto'] |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
847 ret = self.admin.main() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
848 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
849 out = out.getvalue().strip() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
850 print(out) |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
851 expected=('Unknown command "xyzzy" ' |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
852 '("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
|
853 self.assertEqual(expected, out) |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
854 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
855 # 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
|
856 self.admin=AdminTool() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
857 # 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
|
858 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
|
859 ''' 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
|
860 report error. |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
861 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
862 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
|
863 'assignedto'] |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
864 ret = self.admin.main() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
865 |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
866 out = out.getvalue().strip() |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
867 print(out) |
|
81babf5a4494
Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents:
6181
diff
changeset
|
868 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
|
869 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
|
870 |
|
6177
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
871 def testFilter(self): |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
872 ''' 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
|
873 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
|
874 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
|
875 ''' |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
876 self.admin=AdminTool() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
877 self.install_init() |
|
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 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
|
880 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
|
881 'title="foo bar"', 'assignedto=admin' ] |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
882 ret = self.admin.main() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
883 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
884 out = out.getvalue().strip() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
885 print(out) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
886 self.assertEqual(out, '1') |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
887 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
888 self.admin=AdminTool() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
889 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
|
890 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
|
891 'title="bar foo bar"', 'assignedto=anonymous' ] |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
892 ret = self.admin.main() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
893 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
894 out = out.getvalue().strip() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
895 print(out) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
896 self.assertEqual(out, '2') |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
897 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
898 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
899 # Reopen the db closed by previous filter call |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
900 # test string - one results, one value, substring |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
901 self.admin=AdminTool() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
902 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
|
903 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
|
904 'username=admin'] |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
905 ret = self.admin.main() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
906 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
907 out = out.getvalue().strip() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
908 print(out) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
909 self.assertEqual(out, "['1']") |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
910 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
911 # Reopen the db closed by previous filter call |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
912 # test string - two results, two values, substring |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
913 self.admin=AdminTool() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
914 with captured_output() as (out, err): |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
915 ''' 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
|
916 so admin or anonymous |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
917 ''' |
|
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', 'user', |
|
6177
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
919 'username=a,n'] |
|
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 # out can be "['2', '1']" or "['1', '2']" |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
925 # 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
|
926 self.assertEqual(sorted(eval(out)), ['1', '2']) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
927 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
928 # Reopen the db closed by previous filter call |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
929 # test string - one result, two values, substring |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
930 self.admin=AdminTool() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
931 with captured_output() as (out, err): |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
932 ''' 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
|
933 so anonymous |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
934 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
935 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
|
936 'username=a,y'] |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
937 ret = self.admin.main() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
938 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
939 out = out.getvalue().strip() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
940 print(out) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
941 self.assertEqual(out, "['2']") |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
942 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
943 # Reopen the db closed by previous filter call |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
944 # test string - no results |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
945 self.admin=AdminTool() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
946 with captured_output() as (out, err): |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
947 ''' will return empty set as admin!=anonymous |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
948 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
949 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
|
950 'username=admin,anonymous'] |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
951 ret = self.admin.main() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
952 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
953 out = out.getvalue().strip() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
954 print(out) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
955 self.assertEqual(out, "[]") |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
956 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
957 # Reopen the db closed by previous filter call |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
958 # test link using ids |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
959 self.admin=AdminTool() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
960 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
|
961 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
|
962 'assignedto=1,2'] |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
963 ret = self.admin.main() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
964 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
965 out = out.getvalue().strip() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
966 print(out) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
967 self.assertEqual(sorted(eval(out)), ['1', '2']) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
968 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
969 # Reopen the db closed by previous filter call |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
970 # test link using names |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
971 self.admin=AdminTool() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
972 with captured_output() as (out, err): |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
973 ''' will return empty set as admin!=anonymous |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
974 ''' |
|
6189
7458211ca6f3
Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents:
6188
diff
changeset
|
975 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
|
976 'assignedto=admin,anonymous'] |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
977 ret = self.admin.main() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
978 |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
979 out = out.getvalue().strip() |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
980 print(out) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
981 self.assertEqual(sorted(eval(out)), ['1', '2']) |
|
41907e1f9c3f
Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents:
6176
diff
changeset
|
982 |
|
6250
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
983 # 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
|
984 # |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
985 # case: transitive property valid match |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
986 self.admin=AdminTool() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
987 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
|
988 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
|
989 'assignedto.roles=Anonymous'] |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
990 ret = self.admin.main() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
991 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
992 out = out.getvalue().strip() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
993 print(out) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
994 self.assertEqual(out, "['2']") |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
995 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
996 # 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
|
997 # self.admin=AdminTool() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
998 # case: transitive propery invalid prop |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
999 self.admin=AdminTool() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1000 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
|
1001 ''' 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
|
1002 report error. |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1003 ''' |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1004 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
|
1005 'assignedto.badprop=Admin'] |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1006 ret = self.admin.main() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1007 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1008 out = out.getvalue().strip() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1009 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
|
1010 print(out[0:len(expected)]) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1011 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
|
1012 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1013 # 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
|
1014 # |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1015 # case: transitive property invalid match |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1016 self.admin=AdminTool() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1017 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
|
1018 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
|
1019 'filter', 'issue', |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1020 'assignedto.username=NoNAme'] |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1021 ret = self.admin.main() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1022 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1023 out = out.getvalue().strip() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1024 print("me: " + out) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1025 print(err.getvalue().strip()) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1026 self.assertEqual(out, "[]") |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1027 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1028 # 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
|
1029 # |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1030 # case: transitive property invalid match |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1031 self.admin=AdminTool() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1032 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
|
1033 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
|
1034 'filter', 'issue', |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1035 'assignedto.username=NoNAme'] |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1036 ret = self.admin.main() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1037 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1038 out = out.getvalue().strip() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1039 print("me: " + out) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1040 print(err.getvalue().strip()) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1041 self.assertEqual(out, "") |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1042 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1043 # 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
|
1044 # |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1045 # case: transitive property invalid match |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1046 self.admin=AdminTool() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1047 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
|
1048 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
|
1049 'filter', 'issue', |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1050 'assignedto.username=A'] |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1051 ret = self.admin.main() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1052 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1053 out = out.getvalue().strip() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1054 print("me: " + out) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1055 print(err.getvalue().strip()) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1056 self.assertEqual(out, "1,2") |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1057 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1058 # 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
|
1059 # |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1060 # case: transitive property invalid match |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1061 self.admin=AdminTool() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1062 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
|
1063 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
|
1064 'filter', 'issue', |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1065 'assignedto.username=A'] |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1066 ret = self.admin.main() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1067 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1068 out = out.getvalue().strip() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1069 print("me: " + out) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1070 print(err.getvalue().strip()) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1071 self.assertEqual(out, "1 2") |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1072 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1073 # 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
|
1074 # |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1075 # case: transitive property invalid match |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1076 self.admin=AdminTool() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1077 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
|
1078 sys.argv=['main', '-i', self.dirname, '-S', ':', |
|
6251
b303db7f384f
Test designator code path
John Rouillard <rouilj@ieee.org>
parents:
6250
diff
changeset
|
1079 '-d', 'filter', 'issue', |
|
6250
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1080 'assignedto.username=A'] |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1081 ret = self.admin.main() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1082 |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1083 out = out.getvalue().strip() |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1084 print("me: " + out) |
|
95183d73ac64
issue2550522 - add transitive searching to filter in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
6199
diff
changeset
|
1085 print(err.getvalue().strip()) |
|
6251
b303db7f384f
Test designator code path
John Rouillard <rouilj@ieee.org>
parents:
6250
diff
changeset
|
1086 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
|
1087 |
|
7752
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1088 # 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
|
1089 # |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1090 # case: transitive property invalid match |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1091 self.admin=AdminTool() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1092 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
|
1093 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
|
1094 '-d', 'filter', 'issue', |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1095 'assignedto.username=A'] |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1096 ret = self.admin.main() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1097 out = out.getvalue().strip() |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1098 print("me: " + out) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1099 print(err.getvalue().strip()) |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1100 self.assertEqual(out, "['issue1', 'issue2']") |
|
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1101 |
|
7254
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1102 def testPragma_reopen_tracker(self): |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1103 """test that _reopen_tracker works. |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1104 """ |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1105 if self.backend not in ['anydbm']: |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1106 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
|
1107 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1108 orig_input = AdminTool.my_input |
|
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 # 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
|
1111 # and to get "Reopening tracker" verbose log output |
|
8435
1a93dc58f975
feat: add 'q' as alias to quit to exit interactive roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8244
diff
changeset
|
1112 inputs = iter(["pragma verbose=true", "pragma list", "exit"]) |
|
7254
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1113 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1114 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1115 self.install_init() |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1116 self.admin=AdminTool() |
|
7803
2746337ded4c
fix: disable history file changes when testing
John Rouillard <rouilj@ieee.org>
parents:
7802
diff
changeset
|
1117 self.admin.settings['history_features'] = 2 |
|
7254
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1118 sys.argv=['main', '-i', self.dirname] |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1119 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1120 with captured_output() as (out, err): |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1121 ret = self.admin.main() |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1122 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1123 out = out.getvalue().strip().split('\n') |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1124 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1125 print(ret) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1126 self.assertTrue(ret == 0) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1127 expected = ' _reopen_tracker=False' |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1128 self.assertIn(expected, out) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1129 self.assertIn('descriptions...', out[-1]) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1130 self.assertNotIn('Reopening tracker', out) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1131 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1132 # ----- |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1133 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
|
1134 "pragma list", "quit"]) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1135 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1136 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1137 self.install_init() |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1138 self.admin=AdminTool() |
|
7803
2746337ded4c
fix: disable history file changes when testing
John Rouillard <rouilj@ieee.org>
parents:
7802
diff
changeset
|
1139 self.admin.settings['history_features'] = 2 |
|
7254
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1140 sys.argv=['main', '-i', self.dirname] |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1141 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1142 with captured_output() as (out, err): |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1143 ret = self.admin.main() |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1144 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1145 out = out.getvalue().strip().split('\n') |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1146 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1147 print(ret) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1148 self.assertTrue(ret == 0) |
|
8439
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1149 self.assertEqual('Reopening tracker', out[3]) |
|
7254
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1150 expected = ' _reopen_tracker=True' |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1151 self.assertIn(expected, out) |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1152 |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1153 # ----- |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1154 AdminTool.my_input = orig_input |
|
af870e295b46
add test for pragma _reopen_tracker
John Rouillard <rouilj@ieee.org>
parents:
7252
diff
changeset
|
1155 |
|
7252
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1156 def testPragma(self): |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1157 """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
|
1158 commands. |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1159 """ |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1160 if self.backend not in ['anydbm']: |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1161 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
|
1162 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1163 orig_input = AdminTool.my_input |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1164 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1165 for i in ["oN", "1", "yeS", "True"]: |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1166 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
|
1167 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1168 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1169 self.install_init() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1170 self.admin=AdminTool() |
|
7803
2746337ded4c
fix: disable history file changes when testing
John Rouillard <rouilj@ieee.org>
parents:
7802
diff
changeset
|
1171 self.admin.settings['history_features'] = 2 |
|
7252
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1172 sys.argv=['main', '-i', self.dirname] |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1173 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1174 with captured_output() as (out, err): |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1175 ret = self.admin.main() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1176 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1177 out = out.getvalue().strip().split('\n') |
|
8439
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1178 |
|
7252
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1179 print(ret) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1180 self.assertTrue(ret == 0) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1181 expected = ' verbose=True' |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1182 self.assertIn(expected, out) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1183 self.assertIn('descriptions...', out[-1]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1184 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1185 # ----- |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1186 for i in ["oFf", "0", "NO", "FalSe"]: |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1187 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
|
1188 "pragma list", "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') |
|
8439
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1200 |
|
7252
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 = ' verbose=False' |
|
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 # ----- test syntax errors |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1207 inputs = iter(["pragma", "pragma arg", |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1208 "pragma foo=3","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 = 'Error: Not enough arguments supplied' |
|
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 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
|
1226 self.assertIn(expected, out) |
|
7752
b2dbab2b34bc
fix(refactor): multiple fixups using ruff linter; more testing.
John Rouillard <rouilj@ieee.org>
parents:
7650
diff
changeset
|
1227 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
|
1228 self.assertIn(expected, out) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1229 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1230 # ----- |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1231 inputs = iter(["pragma verbose=foo", "quit"]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1232 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1233 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1234 self.install_init() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1235 self.admin=AdminTool() |
|
7803
2746337ded4c
fix: disable history file changes when testing
John Rouillard <rouilj@ieee.org>
parents:
7802
diff
changeset
|
1236 self.admin.settings['history_features'] = 2 |
|
7252
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1237 sys.argv=['main', '-i', self.dirname] |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1238 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1239 with captured_output() as (out, err): |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1240 ret = self.admin.main() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1241 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1242 out = out.getvalue().strip().split('\n') |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1243 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1244 print(ret) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1245 self.assertTrue(ret == 0) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1246 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
|
1247 self.assertIn(expected, out) |
|
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 verbose=on", "pragma _inttest=5", |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1251 "pragma list", "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 self.assertTrue(ret == 0) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1266 expected = ' _inttest=5' |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1267 self.assertIn(expected, out) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1268 self.assertIn('descriptions...', out[-1]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1269 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1270 |
|
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 inputs = iter(["pragma verbose=on", "pragma _inttest=fred", |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1273 "pragma list", "quit"]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1274 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1275 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1276 self.install_init() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1277 self.admin=AdminTool() |
|
7803
2746337ded4c
fix: disable history file changes when testing
John Rouillard <rouilj@ieee.org>
parents:
7802
diff
changeset
|
1278 self.admin.settings['history_features'] = 2 |
|
7252
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1279 sys.argv=['main', '-i', self.dirname] |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1280 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1281 with captured_output() as (out, err): |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1282 ret = self.admin.main() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1283 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1284 out = out.getvalue().strip().split('\n') |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1285 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1286 print(ret) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1287 self.assertTrue(ret == 0) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1288 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
|
1289 self.assertIn(expected, out) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1290 self.assertIn('descriptions...', out[-1]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1291 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1292 # ----- |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1293 inputs = iter(["pragma indexer_backend=whoosh", "pragma list", |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1294 "quit"]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1295 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1296 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1297 self.install_init() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1298 self.admin=AdminTool() |
|
7803
2746337ded4c
fix: disable history file changes when testing
John Rouillard <rouilj@ieee.org>
parents:
7802
diff
changeset
|
1299 self.admin.settings['history_features'] = 2 |
|
7252
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1300 sys.argv=['main', '-i', self.dirname] |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1301 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1302 with captured_output() as (out, err): |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1303 ret = self.admin.main() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1304 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1305 out = out.getvalue().strip().split('\n') |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1306 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1307 print(ret) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1308 expected = ' indexer_backend=whoosh' |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1309 self.assertIn(expected, out) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1310 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1311 # ----- |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1312 inputs = iter(["pragma _floattest=4.5", "quit"]) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1313 AdminTool.my_input = lambda _self, _prompt: next(inputs) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1314 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1315 self.install_init() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1316 self.admin=AdminTool() |
|
7803
2746337ded4c
fix: disable history file changes when testing
John Rouillard <rouilj@ieee.org>
parents:
7802
diff
changeset
|
1317 self.admin.settings['history_features'] = 2 |
|
7252
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1318 sys.argv=['main', '-i', self.dirname] |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1319 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1320 with captured_output() as (out, err): |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1321 ret = self.admin.main() |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1322 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1323 out = out.getvalue().strip().split('\n') |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1324 |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1325 print(ret) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1326 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
|
1327 self.assertIn(expected, out) |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1328 |
|
7543
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1329 |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1330 # ----- |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1331 inputs = iter(["pragma display_protected=yes", |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1332 "display user1", |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1333 "quit"]) |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1334 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
|
1335 |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1336 self.install_init() |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1337 self.admin=AdminTool() |
|
7803
2746337ded4c
fix: disable history file changes when testing
John Rouillard <rouilj@ieee.org>
parents:
7802
diff
changeset
|
1338 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
|
1339 sys.argv=['main', '-i', self.dirname] |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1340 |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1341 with captured_output() as (out, err): |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1342 ret = self.admin.main() |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1343 |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1344 out = out.getvalue().strip() |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1345 |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1346 print(ret) |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1347 expected = '\n*creation: ' |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1348 self.assertIn(expected, out) |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
1349 |
|
7252
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1350 # ----- |
|
9c067ed4568b
add pragma command to roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7205
diff
changeset
|
1351 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
|
1352 |
|
7395
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1353 def testReindex(self): |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1354 ''' 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
|
1355 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
|
1356 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
|
1357 ''' |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1358 self.install_init() |
|
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 # create an issue |
|
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 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
|
1363 'title="foo bar"', 'assignedto=admin' ] |
|
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 # reindex everything |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1367 self.admin=AdminTool() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1368 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
|
1369 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
|
1370 ret = self.admin.main() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1371 out = out.getvalue().strip() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1372 print(len(out)) |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1373 print(repr(out)) |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1374 # 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
|
1375 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
|
1376 |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1377 |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1378 # reindex whole class |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1379 self.admin=AdminTool() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1380 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
|
1381 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
|
1382 ret = self.admin.main() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1383 |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1384 out = out.getvalue().strip() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1385 print(len(out)) |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1386 print(repr(out)) |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1387 self.assertEqual(out, |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1388 '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
|
1389 self.assertEqual(len(out), 170) |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1390 |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1391 # reindex one item |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1392 self.admin=AdminTool() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1393 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
|
1394 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
|
1395 ret = self.admin.main() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1396 |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1397 out = out.getvalue().strip() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1398 print(len(out)) |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1399 print(repr(out)) |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1400 # 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
|
1401 self.assertEqual(out, '') |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1402 |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1403 # reindex range |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1404 self.admin=AdminTool() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1405 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
|
1406 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
|
1407 ret = self.admin.main() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1408 |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1409 out = out.getvalue().strip() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1410 print(repr(out)) |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1411 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
|
1412 |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1413 # reindex bad class |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1414 self.admin=AdminTool() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1415 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
|
1416 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
|
1417 ret = self.admin.main() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1418 |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1419 out = out.getvalue().strip() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1420 print(repr(out)) |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1421 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
|
1422 |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1423 # reindex bad item |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1424 self.admin=AdminTool() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1425 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
|
1426 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
|
1427 ret = self.admin.main() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1428 |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1429 out = out.getvalue().strip() |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1430 print(repr(out)) |
|
312d52305583
- issue2551190 - Allow roundup-admin reindex to work in batches.
John Rouillard <rouilj@ieee.org>
parents:
7392
diff
changeset
|
1431 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
|
1432 |
| 6199 | 1433 def disabletestHelpInitopts(self): |
| 1434 | |
| 1435 ''' Note the tests will fail if you run this under pdb. | |
| 1436 the context managers capture the pdb prompts and this screws | |
| 1437 up the stdout strings with (pdb) prefixed to the line. | |
| 1438 ''' | |
| 1439 self.install_init() | |
| 1440 self.admin=AdminTool() | |
| 1441 | |
| 1442 with captured_output() as (out, err): | |
| 1443 sys.argv=['main', '-i', self.dirname, 'help', 'initopts'] | |
| 1444 ret = self.admin.main() | |
| 1445 | |
| 1446 out = out.getvalue().strip() | |
| 1447 expected = [ | |
| 1448 'Templates: minimal, jinja2, classic, responsive, devel', | |
| 1449 'Back ends: anydbm, sqlite' | |
| 1450 ] | |
| 1451 print(out) | |
| 1452 self.assertTrue(expected[0] in out) | |
| 1453 self.assertTrue("Back ends:" in out) | |
| 1454 | |
|
7650
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1455 def testSecurityListOne(self): |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1456 self.install_init() |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1457 self.admin=AdminTool() |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1458 |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1459 with captured_output() as (out, err): |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1460 # 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
|
1461 # lower cased interally |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1462 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
|
1463 ret = self.admin.main() |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1464 |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1465 result = """Role "user": |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1466 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
|
1467 User may access the rest interface (Rest Access) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1468 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
|
1469 User may access the xmlrpc interface (Xmlrpc Access) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1470 User is allowed to create file (Create for "file" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1471 User is allowed to edit file (Edit for "file" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1472 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
|
1473 User is allowed to create issue (Create for "issue" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1474 User is allowed to edit issue (Edit for "issue" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1475 User is allowed to access issue (View for "issue" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1476 User is allowed to create keyword (Create for "keyword" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1477 User is allowed to edit keyword (Edit for "keyword" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1478 User is allowed to access keyword (View for "keyword" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1479 User is allowed to create msg (Create for "msg" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1480 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
|
1481 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
|
1482 User is allowed to access priority (View for "priority" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1483 User is allowed to create queries (Create for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1484 User is allowed to edit their queries (Edit for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1485 User is allowed to restore their queries (Restore for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1486 User is allowed to retire their queries (Retire for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1487 (Search for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1488 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
|
1489 User is allowed to access status (View for "status" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1490 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
|
1491 (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
|
1492 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
|
1493 """ |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1494 print(out.getvalue()) |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1495 |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1496 self.assertEqual(result, out.getvalue()) |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1497 self.assertEqual(ret, 0) |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1498 |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1499 |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1500 # 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
|
1501 # 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
|
1502 self.admin=AdminTool() |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1503 with captured_output() as (out, err): |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1504 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
|
1505 ret = self.admin.main() |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1506 |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1507 print(out.getvalue()) |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1508 |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1509 self.assertEqual(result, out.getvalue()) |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1510 self.assertEqual(ret, 0) |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1511 |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1512 # 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
|
1513 self.admin=AdminTool() |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1514 with captured_output() as (out, err): |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1515 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
|
1516 ret = self.admin.main() |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1517 |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1518 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
|
1519 print('>', out.getvalue()) |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1520 |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1521 self.assertEqual(result, out.getvalue()) |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1522 self.assertEqual(ret, 1) |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1523 |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1524 |
|
4de48eadf5f4
bug: Fix roundup-admin security command. Lowercase optionalarg.
John Rouillard <rouilj@ieee.org>
parents:
7586
diff
changeset
|
1525 def testSecurityListAll(self): |
|
6393
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1526 ''' 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
|
1527 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
|
1528 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
|
1529 ''' |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1530 self.install_init() |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1531 self.admin=AdminTool() |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1532 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1533 with captured_output() as (out, err): |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1534 sys.argv=['main', '-i', self.dirname, 'security' ] |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1535 ret = self.admin.main() |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1536 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1537 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
|
1538 New Email users get the Role "User" |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1539 Role "admin": |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1540 User may create everything (Create) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1541 User may edit everything (Edit) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1542 User may use the email interface (Email Access) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1543 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
|
1544 User may restore everything (Restore) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1545 User may retire everything (Retire) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1546 User may view everything (View) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1547 User may access the web interface (Web Access) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1548 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
|
1549 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
|
1550 Role "anonymous": |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1551 User may access the web interface (Web Access) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1552 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
|
1553 User is allowed to access issue (View for "issue" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1554 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
|
1555 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
|
1556 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
|
1557 User is allowed to access status (View for "status" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1558 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
|
1559 (Search for "user" only) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1560 Role "user": |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1561 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
|
1562 User may access the rest interface (Rest Access) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1563 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
|
1564 User may access the xmlrpc interface (Xmlrpc Access) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1565 User is allowed to create file (Create for "file" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1566 User is allowed to edit file (Edit for "file" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1567 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
|
1568 User is allowed to create issue (Create for "issue" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1569 User is allowed to edit issue (Edit for "issue" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1570 User is allowed to access issue (View for "issue" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1571 User is allowed to create keyword (Create for "keyword" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1572 User is allowed to edit keyword (Edit for "keyword" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1573 User is allowed to access keyword (View for "keyword" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1574 User is allowed to create msg (Create for "msg" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1575 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
|
1576 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
|
1577 User is allowed to access priority (View for "priority" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1578 User is allowed to create queries (Create for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1579 User is allowed to edit their queries (Edit for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1580 User is allowed to restore their queries (Restore for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1581 User is allowed to retire their queries (Retire for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1582 (Search for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1583 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
|
1584 User is allowed to access status (View for "status" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1585 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
|
1586 (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
|
1587 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
|
1588 """ |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1589 print(out.getvalue()) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1590 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1591 self.assertEqual(result, out.getvalue()) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1592 self.assertEqual(ret, 0) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1593 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1594 def testSecurityInvalidAttribute(self): |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1595 ''' Test with an invalid attribute. |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1596 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
|
1597 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
|
1598 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
|
1599 ''' |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1600 self.maxDiff = None # we want full diff |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1601 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1602 self.install_init() |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1603 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1604 # edit in an invalid attribute/property |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1605 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
|
1606 d = f.readlines() |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1607 f.seek(0) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1608 for i in d: |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1609 if "organisation" in i: |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1610 i = i.replace("'id', 'organisation'","'id', 'organization'") |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1611 f.write(i) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1612 f.truncate() |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1613 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1614 self.admin=AdminTool() |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1615 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1616 with captured_output() as (out, err): |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1617 sys.argv=['main', '-i', self.dirname, 'security' ] |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1618 ret = self.admin.main() |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1619 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1620 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
|
1621 New Email users get the Role "User" |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1622 Role "admin": |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1623 User may create everything (Create) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1624 User may edit everything (Edit) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1625 User may use the email interface (Email Access) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1626 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
|
1627 User may restore everything (Restore) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1628 User may retire everything (Retire) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1629 User may view everything (View) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1630 User may access the web interface (Web Access) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1631 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
|
1632 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
|
1633 Role "anonymous": |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1634 User may access the web interface (Web Access) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1635 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
|
1636 User is allowed to access issue (View for "issue" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1637 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
|
1638 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
|
1639 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
|
1640 User is allowed to access status (View for "status" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1641 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
|
1642 (Search for "user" only) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1643 Role "user": |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1644 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
|
1645 User may access the rest interface (Rest Access) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1646 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
|
1647 User may access the xmlrpc interface (Xmlrpc Access) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1648 User is allowed to create file (Create for "file" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1649 User is allowed to edit file (Edit for "file" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1650 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
|
1651 User is allowed to create issue (Create for "issue" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1652 User is allowed to edit issue (Edit for "issue" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1653 User is allowed to access issue (View for "issue" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1654 User is allowed to create keyword (Create for "keyword" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1655 User is allowed to edit keyword (Edit for "keyword" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1656 User is allowed to access keyword (View for "keyword" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1657 User is allowed to create msg (Create for "msg" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1658 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
|
1659 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
|
1660 User is allowed to access priority (View for "priority" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1661 User is allowed to create queries (Create for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1662 User is allowed to edit their queries (Edit for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1663 User is allowed to restore their queries (Restore for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1664 User is allowed to retire their queries (Retire for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1665 (Search for "query" only) |
|
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1666 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
|
1667 User is allowed to access status (View for "status" only) |
|
8119
c12377fb4144
Change permission representation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7883
diff
changeset
|
1668 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
|
1669 (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
|
1670 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1671 **Invalid properties for user: ['organization'] |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1672 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1673 """ |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1674 print(out.getvalue()) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1675 |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1676 self.assertEqual(result, out.getvalue()) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1677 self.assertEqual(ret, 1) |
|
51a1a9b0f567
- issue2551062: AddPermission doesn't validate property names.
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1678 |
|
6181
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1679 def testSet(self): |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1680 ''' 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
|
1681 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
|
1682 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
|
1683 ''' |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1684 self.install_init() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1685 self.admin=AdminTool() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1686 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1687 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
|
1688 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
|
1689 '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
|
1690 ret = self.admin.main() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1691 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1692 out = out.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1693 print(out) |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1694 self.assertEqual(out, '1') |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1695 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1696 self.admin=AdminTool() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1697 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
|
1698 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
|
1699 '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
|
1700 ret = self.admin.main() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1701 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1702 out = out.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1703 print(out) |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1704 self.assertEqual(out, '2') |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1705 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1706 self.admin=AdminTool() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1707 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
|
1708 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
|
1709 ret = self.admin.main() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1710 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1711 out = out.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1712 err = err.getvalue().strip() |
|
6332
6a6b4651be1f
Use server-side cursor for postgres in some cases
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6251
diff
changeset
|
1713 self.assertEqual(out, '') |
|
6a6b4651be1f
Use server-side cursor for postgres in some cases
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6251
diff
changeset
|
1714 self.assertEqual(err, '') |
|
6181
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1715 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1716 self.admin=AdminTool() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1717 with captured_output() as (out, err): |
| 6199 | 1718 sys.argv=['main', '-i', self.dirname, 'set', 'issue2', |
| 1719 'tile="new title"'] | |
|
6181
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1720 ret = self.admin.main() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1721 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1722 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
|
1723 |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1724 out = out.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1725 err = err.getvalue().strip() |
|
49f599f187e1
Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents:
6178
diff
changeset
|
1726 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
|
1727 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
|
1728 |
| 6199 | 1729 self.admin=AdminTool() |
| 1730 with captured_output() as (out, err): | |
| 1731 sys.argv=['main', '-i', self.dirname, 'set', 'issue2'] | |
| 1732 ret = self.admin.main() | |
| 1733 | |
| 1734 expected_err = "Error: Not enough arguments supplied" | |
| 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 | |
| 1742 self.admin=AdminTool() | |
| 1743 with captured_output() as (out, err): | |
| 1744 sys.argv=['main', '-i', self.dirname, 'set', | |
| 1745 'issue2,issue1,issue', "status=1" ] | |
| 1746 ret = self.admin.main() | |
| 1747 | |
| 1748 expected_err = 'Error: "issue" not a node designator' | |
| 1749 | |
| 1750 out = out.getvalue().strip() | |
| 1751 err = err.getvalue().strip() | |
| 1752 self.assertEqual(out.index(expected_err), 0) | |
| 1753 self.assertEqual(len(err), 0) | |
| 1754 | |
| 1755 self.admin=AdminTool() | |
| 1756 with captured_output() as (out, err): | |
| 1757 sys.argv=['main', '-i', self.dirname, 'set', | |
| 1758 'issue2,issue1,user2', "status=1" ] | |
| 1759 ret = self.admin.main() | |
| 1760 | |
| 1761 expected_err = "Error: 'status' is not a property of user" | |
| 1762 | |
| 1763 out = out.getvalue().strip() | |
| 1764 err = err.getvalue().strip() | |
| 1765 print(out) | |
| 1766 print(expected_err) | |
| 1767 print(err) | |
| 1768 self.assertEqual(out.index(expected_err), 0) | |
| 1769 self.assertEqual(len(err), 0) | |
| 1770 | |
| 1771 self.admin=AdminTool() | |
| 1772 with captured_output() as (out, err): | |
| 1773 sys.argv=['main', '-i', self.dirname, 'set', | |
| 1774 'issue2,issue1,issue1000', "status=1" ] | |
| 1775 ret = self.admin.main() | |
| 1776 | |
| 1777 expected_err = 'Error: no such issue 1000' | |
| 1778 | |
| 1779 out = out.getvalue().strip() | |
| 1780 err = err.getvalue().strip() | |
| 1781 self.assertEqual(out.index(expected_err), 0) | |
| 1782 self.assertEqual(len(err), 0) | |
| 1783 | |
| 1784 def testSetOnClass(self): | |
| 1785 ''' Note the tests will fail if you run this under pdb. | |
| 1786 the context managers capture the pdb prompts and this screws | |
| 1787 up the stdout strings with (pdb) prefixed to the line. | |
| 1788 ''' | |
| 1789 self.install_init() | |
| 1790 | |
| 1791 self.admin=AdminTool() | |
| 1792 with captured_output() as (out, err): | |
| 1793 sys.argv=['main', '-i', self.dirname, 'create', 'issue', | |
| 1794 'title="foo bar"', 'assignedto=admin' ] | |
| 1795 ret = self.admin.main() | |
| 1796 | |
| 1797 out = out.getvalue().strip() | |
| 1798 print(out) | |
| 1799 self.assertEqual(out, '1') | |
| 1800 | |
| 1801 self.admin=AdminTool() | |
| 1802 with captured_output() as (out, err): | |
| 1803 sys.argv=['main', '-i', self.dirname, 'create', 'issue', | |
| 1804 'title="bar foo bar"', 'assignedto=anonymous' ] | |
| 1805 ret = self.admin.main() | |
| 1806 | |
| 1807 out = out.getvalue().strip() | |
| 1808 print(out) | |
| 1809 self.assertEqual(out, '2') | |
| 1810 | |
| 1811 # Run this test in a separate test. | |
| 1812 # It can cause a database timeout/resource | |
| 1813 # unavailable error for anydbm when run with other tests. | |
| 1814 # Not sure why. | |
| 1815 # Set assignedto=2 for all issues | |
| 1816 ## verify that issue 1 and 2 are assigned to user1 and user2 | |
| 1817 self.admin=AdminTool() | |
| 1818 with captured_output() as (out, err): | |
| 1819 sys.argv=['main', '-i', self.dirname, 'table', 'issue', | |
| 1820 'assignedto'] | |
| 1821 ret = self.admin.main() | |
| 1822 | |
| 1823 expected = "Assignedto\n1 \n2" | |
| 1824 out = out.getvalue().strip() | |
| 1825 err = err.getvalue().strip() | |
| 1826 self.assertEqual(out, expected) | |
| 1827 self.assertEqual(len(err), 0) | |
| 1828 self.admin=AdminTool() | |
| 1829 # do the set | |
| 1830 with captured_output() as (out, err): | |
| 1831 sys.argv=['main', '-i', self.dirname, 'set', 'issue', | |
| 1832 'assignedto=2'] | |
| 1833 ret = self.admin.main() | |
| 1834 | |
| 1835 expected_err = "" | |
| 1836 | |
| 1837 out = out.getvalue().strip() | |
| 1838 err = err.getvalue().strip() | |
|
6332
6a6b4651be1f
Use server-side cursor for postgres in some cases
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6251
diff
changeset
|
1839 self.assertEqual(out, '') |
|
6a6b4651be1f
Use server-side cursor for postgres in some cases
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6251
diff
changeset
|
1840 self.assertEqual(err, '') |
| 6199 | 1841 |
| 1842 ## verify that issue 1 and 2 are assigned to user2 and user2 | |
| 1843 self.admin=AdminTool() | |
| 1844 with captured_output() as (out, err): | |
| 1845 sys.argv=['main', '-i', self.dirname, 'table', 'issue', | |
| 1846 'assignedto'] | |
| 1847 ret = self.admin.main() | |
| 1848 | |
| 1849 expected = "Assignedto\n2 \n2" | |
| 1850 out = out.getvalue().strip() | |
| 1851 err = err.getvalue().strip() | |
| 1852 self.assertEqual(out, expected) | |
| 1853 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
|
1854 |
|
8439
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1855 def testReadline(self): |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1856 ''' Note the tests will fail if you run this under pdb. |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1857 the context managers capture the pdb prompts and this screws |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1858 up the stdout strings with (pdb) prefixed to the line. |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1859 ''' |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1860 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1861 '''history didn't work when testing. The commands being |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1862 executed aren't being sent into the history |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1863 buffer. Failed under both windows and linux. |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1864 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1865 Explicitly using: readline.set_auto_history(True) in |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1866 roundup-admin setup had no effect. |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1867 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1868 Looks like monkeypatching stdin is the issue since: |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1869 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1870 printf... | roundup-admin | tee |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1871 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1872 doesn't work either when printf uses |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1873 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1874 "readline vi\nreadline emacs\nreadline history\nquit\n" |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1875 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1876 Added explicit readline.add_history() if stdin or |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1877 stdout are not a tty to admin.py:interactive(). |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1878 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1879 Still no way to drive editing with control/escape |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1880 chars to verify editing mode, check keybindings. Need |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1881 to trick Admintool to believe it's running on a |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1882 tty/pty/con in linux/windows to remove my hack. |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1883 ''' |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1884 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1885 # Put the init file in the tracker test directory so |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1886 # we don't clobber user's actual init file. |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1887 original_home = None |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1888 if 'HOME' in os.environ: |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1889 original_home = os.environ['HOME'] |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1890 os.environ['HOME'] = self.dirname |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1891 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1892 # same but for windows. |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1893 original_userprofile = None |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1894 if 'USERPROFILE' in os.environ: |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1895 # windows |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1896 original_userprofile = os.environ['USERPROFILE'] |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1897 os.environ['USERPROFILE'] = self.dirname |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1898 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1899 inputs = ["readline vi", "readline emacs", "readline reload", "quit"] |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1900 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1901 self._monkeypatch.setattr( |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1902 'sys.stdin', |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1903 io.StringIO("\n".join(inputs))) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1904 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1905 self.install_init() |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1906 self.admin=AdminTool() |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1907 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1908 # disable loading and saving history |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1909 self.admin.settings['history_features'] = 3 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1910 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1911 # verify correct init file is being |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1912 self.assertIn(os.path.join(os.path.expanduser("~"), |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1913 ".roundup_admin_rlrc"), |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1914 self.admin.get_readline_init_file()) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1915 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1916 # No exception is raised for missing file |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1917 # under pyreadline3. Detect pyreadline3 looking for: |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1918 # readline.Readline |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1919 pyreadline = hasattr(self.admin.readline, "Readline") |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1920 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1921 sys.argv=['main', '-i', self.dirname] |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1922 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1923 with captured_output() as (out, err): |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1924 ret = self.admin.main() |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1925 out = out.getvalue().strip().split('\n') |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1926 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1927 print(ret) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1928 self.assertTrue(ret == 0) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1929 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1930 expected = 'roundup> Enabled vi mode.' |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1931 self.assertIn(expected, out) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1932 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1933 expected = 'roundup> Enabled emacs mode.' |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1934 self.assertIn(expected, out) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1935 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1936 if not pyreadline: |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1937 expected = ('roundup> Init file %s ' |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1938 'not found.' % self.admin.get_readline_init_file()) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1939 self.assertIn(expected, out) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1940 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1941 # --- test 2 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1942 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1943 inputs = ["readline reload", "q"] |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1944 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1945 self._monkeypatch.setattr( |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1946 'sys.stdin', |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1947 io.StringIO("\n".join(inputs))) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1948 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1949 self.install_init() |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1950 self.admin=AdminTool() |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1951 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1952 with open(self.admin.get_readline_init_file(), |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1953 "w") as config_file: |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1954 # there is no config line that works for all |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1955 # pyreadline3 (windows), readline(*nix), or editline |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1956 # (mac). So write empty file. |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1957 config_file.write("") |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1958 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1959 # disable loading and saving history |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1960 self.admin.settings['history_features'] = 3 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1961 sys.argv=['main', '-i', self.dirname] |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1962 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1963 with captured_output() as (out, err): |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1964 ret = self.admin.main() |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1965 out = out.getvalue().strip().split('\n') |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1966 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1967 print(ret) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1968 self.assertTrue(ret == 0) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1969 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1970 expected = ('roundup> File %s reloaded.' % |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1971 self.admin.get_readline_init_file()) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1972 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1973 self.assertIn(expected, out) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
1974 |
|
8440
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1975 # --- test 3,4 - make sure readline gets history_length pragma. |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1976 # test CLI and interactive. |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1977 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1978 inputs = ["pragma list", "q"] |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1979 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1980 self._monkeypatch.setattr( |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1981 'sys.stdin', |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1982 io.StringIO("\n".join(inputs))) |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1983 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1984 self.install_init() |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1985 self.admin=AdminTool() |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1986 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1987 # disable all config/history |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1988 self.admin.settings['history_features'] = 7 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1989 sys.argv=['main', '-i', self.dirname, '-P', 'history_length=11'] |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1990 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1991 with captured_output() as (out, err): |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1992 ret = self.admin.main() |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1993 out = out.getvalue().strip().split('\n') |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1994 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1995 print(ret) |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1996 self.assertTrue(ret == 0) |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1997 self.assertEqual(self.admin.readline.get_history_length(), |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1998 11) |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
1999 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2000 # 4 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2001 inputs = ["pragma history_length=17", "q"] |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2002 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2003 self._monkeypatch.setattr( |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2004 'sys.stdin', |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2005 io.StringIO("\n".join(inputs))) |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2006 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2007 self.install_init() |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2008 self.admin=AdminTool() |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2009 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2010 # disable all config/history |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2011 self.admin.settings['history_features'] = 7 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2012 # keep pragma in CLI. Make sure it's overridden by interactive |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2013 sys.argv=['main', '-i', self.dirname, '-P', 'history_length=11'] |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2014 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2015 with captured_output() as (out, err): |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2016 ret = self.admin.main() |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2017 out = out.getvalue().strip().split('\n') |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2018 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2019 print(ret) |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2020 self.assertTrue(ret == 0) |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2021 # should not be 11. |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2022 self.assertEqual(self.admin.readline.get_history_length(), |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2023 17) |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2024 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2025 # --- test 5 invalid single word parameter |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2026 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2027 inputs = ["readline nosuchdirective", "q"] |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2028 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2029 self._monkeypatch.setattr( |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2030 'sys.stdin', |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2031 io.StringIO("\n".join(inputs))) |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2032 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2033 self.install_init() |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2034 self.admin=AdminTool() |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2035 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2036 # disable loading and saving history |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2037 self.admin.settings['history_features'] = 3 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2038 sys.argv=['main', '-i', self.dirname] |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2039 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2040 with captured_output() as (out, err): |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2041 ret = self.admin.main() |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2042 out = out.getvalue().strip().split('\n') |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2043 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2044 print(ret) |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2045 self.assertTrue(ret == 0) |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2046 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2047 expected = ('roundup> Unknown readline parameter nosuchdirective') |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2048 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2049 self.assertIn(expected, out) |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2050 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2051 # --- test 6 set keystroke command. |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2052 # FIXME: unable to test key binding/setting actually works. |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2053 # |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2054 # No errors seem to come back from readline or |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2055 # pyreadline3 even when the keybinding makes no |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2056 # sense. Errors are only reported when reading |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2057 # from init file. Using "set answer 42" does print |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2058 # 'readline: answer: unknown variable name' when |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2059 # attached to tty/pty and interactive, but not |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2060 # inside test case. Pyreadline3 doesn't |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2061 # report errors at all. |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2062 # |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2063 # Even if I set a keybidning, I can't invoke it |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2064 # because I am not running inside a pty, so |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2065 # editing is disabled and I have no way to |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2066 # simulate keyboard keystrokes for readline to act |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2067 # upon. |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2068 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2069 inputs = ['readline set meaning 42', "q"] |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2070 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2071 self._monkeypatch.setattr( |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2072 'sys.stdin', |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2073 io.StringIO("\n".join(inputs))) |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2074 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2075 self.install_init() |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2076 self.admin=AdminTool() |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2077 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2078 # disable loading and saving history |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2079 self.admin.settings['history_features'] = 3 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2080 sys.argv=['main', '-i', self.dirname] |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2081 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2082 with captured_output() as (out, err): |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2083 ret = self.admin.main() |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2084 out = out.getvalue().strip().split('\n') |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2085 |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2086 print(ret) |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2087 self.assertTrue(ret == 0) |
|
254f70dfc585
bug, refactor, test: make pragma history_length work interactively
John Rouillard <rouilj@ieee.org>
parents:
8439
diff
changeset
|
2088 |
|
8439
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2089 # === cleanup |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2090 if original_home: |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2091 os.environ['HOME'] = original_home |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2092 if original_userprofile: |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2093 os.environ['USERPROFILE'] = original_userprofile |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2094 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2095 def test_admin_history_save_load(self): |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2096 # To prevent overwriting/reading user's actual history, |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2097 # change HOME enviroment var. |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2098 original_home = None |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2099 if 'HOME' in os.environ: |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2100 original_home = os.environ['HOME'] |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2101 os.environ['HOME'] = self.dirname |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2102 os.environ['HOME'] = self.dirname |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2103 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2104 # same idea but windows |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2105 original_userprofile = None |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2106 if 'USERPROFILE' in os.environ: |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2107 # windows |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2108 original_userprofile = os.environ['USERPROFILE'] |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2109 os.environ['USERPROFILE'] = self.dirname |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2110 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2111 # -- history test |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2112 inputs = ["readline history", "q"] |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2113 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2114 self._monkeypatch.setattr( |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2115 'sys.stdin', |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2116 io.StringIO("\n".join(inputs))) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2117 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2118 self.install_init() |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2119 self.admin=AdminTool() |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2120 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2121 # use defaults load/save history |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2122 self.admin.settings['history_features'] = 0 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2123 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2124 sys.argv=['main', '-i', self.dirname] |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2125 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2126 with captured_output() as (out, err): |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2127 ret = self.admin.main() |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2128 out = out.getvalue().strip().split('\n') |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2129 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2130 print(ret) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2131 self.assertTrue(ret == 0) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2132 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2133 expected = 'roundup> history size 1' |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2134 self.assertIn(expected, out) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2135 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2136 expected = ' 1 readline history' |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2137 self.assertIn(expected, out) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2138 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2139 # -- history test 3 reruns readline vi |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2140 inputs = ["readline vi", "readline history", "!3", |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2141 "readline history", "!23s", "q"] |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2142 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2143 self._monkeypatch.setattr( |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2144 'sys.stdin', |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2145 io.StringIO("\n".join(inputs))) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2146 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2147 # preserve directory self.install_init() |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2148 self.admin=AdminTool() |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2149 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2150 # default use all features |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2151 #self.admin.settings['history_features'] = 3 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2152 sys.argv=['main', '-i', self.dirname] |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2153 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2154 with captured_output() as (out, err): |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2155 ret = self.admin.main() |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2156 out = out.getvalue().strip().split('\n') |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2157 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2158 print(ret) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2159 self.assertTrue(ret == 0) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2160 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2161 # 4 includes 2 commands in saved history |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2162 expected = 'roundup> history size 4' |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2163 self.assertIn(expected, out) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2164 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2165 expected = ' 4 readline history' |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2166 self.assertIn(expected, out) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2167 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2168 # Shouldn't work on windows. |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2169 if platform.system() != "Windows": |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2170 expected = ' 5 readline vi' |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2171 self.assertIn(expected, out) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2172 else: |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2173 # PYREADLINE UNDER WINDOWS |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2174 # py3readline on windows can't replace |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2175 # command strings in history when connected |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2176 # to a console. (Console triggers autosave and |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2177 # I have to turn !3 into it's substituted value.) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2178 # but in testing autosave is disabled so |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2179 # I don't get the !number but the actual command |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2180 # It should have |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2181 # |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2182 # expected = ' 5 !3' |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2183 # |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2184 # but it is the same as the unix case. |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2185 expected = ' 5 readline vi' |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2186 self.assertIn(expected, out) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2187 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2188 expected = ('roundup> Unknown command "!23s" ("help commands" ' |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2189 'for a list)') |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2190 self.assertIn(expected, out) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2191 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2192 print(out) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2193 # can't test !#:p mode as readline editing doesn't work |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2194 # if not in a tty. |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2195 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2196 # === cleanup |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2197 if original_home: |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2198 os.environ['HOME'] = original_home |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2199 if original_userprofile: |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2200 os.environ['USERPROFILE'] = original_userprofile |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2201 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2202 def test_admin_readline_history(self): |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2203 original_home = os.environ['HOME'] |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2204 # To prevent overwriting/reading user's actual history, |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2205 # change HOME enviroment var. |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2206 os.environ['HOME'] = self.dirname |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2207 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2208 original_userprofile = None |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2209 if 'USERPROFILE' in os.environ: |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2210 # windows |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2211 original_userprofile = os.environ['USERPROFILE'] |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2212 os.environ['USERPROFILE'] = self.dirname |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2213 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2214 # -- history test |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2215 inputs = ["readline history", "q"] |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2216 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2217 self._monkeypatch.setattr( |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2218 'sys.stdin', |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2219 io.StringIO("\n".join(inputs))) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2220 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2221 self.install_init() |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2222 self.admin=AdminTool() |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2223 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2224 # disable loading, but save history |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2225 self.admin.settings['history_features'] = 3 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2226 sys.argv=['main', '-i', self.dirname] |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2227 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2228 with captured_output() as (out, err): |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2229 ret = self.admin.main() |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2230 out = out.getvalue().strip().split('\n') |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2231 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2232 print(ret) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2233 self.assertTrue(ret == 0) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2234 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2235 expected = 'roundup> history size 1' |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2236 self.assertIn(expected, out) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2237 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2238 expected = ' 1 readline history' |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2239 self.assertIn(expected, out) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2240 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2241 # -- history test |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2242 inputs = ["readline vi", "readline history", "!1", "!2", "q"] |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2243 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2244 self._monkeypatch.setattr( |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2245 'sys.stdin', |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2246 io.StringIO("\n".join(inputs))) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2247 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2248 self.install_init() |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2249 self.admin=AdminTool() |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2250 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2251 # disable loading, but save history |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2252 self.admin.settings['history_features'] = 3 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2253 sys.argv=['main', '-i', self.dirname] |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2254 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2255 with captured_output() as (out, err): |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2256 ret = self.admin.main() |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2257 out = out.getvalue().strip().split('\n') |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2258 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2259 print(ret) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2260 self.assertTrue(ret == 0) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2261 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2262 expected = 'roundup> history size 2' |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2263 self.assertIn(expected, out) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2264 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2265 expected = ' 2 readline history' |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2266 self.assertIn(expected, out) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2267 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2268 # doesn't work on windows. |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2269 if platform.system() != "Windows": |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2270 expected = ' 4 readline history' |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2271 self.assertIn(expected, out) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2272 else: |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2273 # See |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2274 # PYREADLINE UNDER WINDOWS |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2275 # elsewhere in this file for why I am not checking for |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2276 # expected = ' 4 !2' |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2277 expected = ' 4 readline history' |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2278 self.assertIn(expected, out) |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2279 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2280 # can't test !#:p mode as readline editing doesn't work |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2281 # if not in a tty. |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2282 |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2283 # === cleanup |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2284 os.environ['HOME'] = original_home |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2285 if original_userprofile: |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2286 os.environ['USERPROFILE'] = original_userprofile |
|
3bdae15252c6
feat: add support for ! history and readline command in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
8435
diff
changeset
|
2287 |
|
6176
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
2288 def testSpecification(self): |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
2289 ''' 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
|
2290 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
|
2291 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
|
2292 ''' |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
2293 self.install_init() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
2294 self.admin=AdminTool() |
|
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
2295 |
|
6178
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
2296 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
|
2297 'alternate_addresses: <roundup.hyperdb.String>', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
2298 'realname: <roundup.hyperdb.String>', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
2299 'roles: <roundup.hyperdb.String>', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
2300 'organisation: <roundup.hyperdb.String>', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
2301 'queries: <roundup.hyperdb.Multilink to "query">', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
2302 'phone: <roundup.hyperdb.String>', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
2303 'address: <roundup.hyperdb.String>', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
2304 'timezone: <roundup.hyperdb.String>', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
2305 'password: <roundup.hyperdb.Password>', |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
2306 ] |
|
7543
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
2307 |
|
6178
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
2308 |
|
6176
d25638d1826c
Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents:
5762
diff
changeset
|
2309 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
|
2310 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
|
2311 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
|
2312 |
|
6178
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
2313 outlist = out.getvalue().strip().split("\n") |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
2314 print(outlist) |
|
227c05ce2d85
Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents:
6177
diff
changeset
|
2315 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
|
2316 |
|
7543
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
2317 # ----- |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
2318 self.install_init() |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
2319 self.admin=AdminTool() |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
2320 |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
2321 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
|
2322 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
|
2323 'display_protected=1', 'specification', 'user'] |
|
7543
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
2324 ret = self.admin.main() |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
2325 |
|
7546
534f8bdb8f94
Add -P pragma=value command line option to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7543
diff
changeset
|
2326 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
|
2327 |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
2328 protected = [ 'id: <roundup.hyperdb.String>', |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
2329 'creation: <roundup.hyperdb.Date>', |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
2330 'activity: <roundup.hyperdb.Date>', |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
2331 'creator: <roundup.hyperdb.Link to "user">', |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
2332 'actor: <roundup.hyperdb.Link to "user">'] |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
2333 print(outlist) |
|
fc9daba984c0
- issue2551103 - add pragma 'display_protected' to roundup-admin.
John Rouillard <rouilj@ieee.org>
parents:
7395
diff
changeset
|
2334 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
|
2335 |
|
6430
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
2336 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
|
2337 ''' 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
|
2338 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
|
2339 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
|
2340 ''' |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
2341 # 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
|
2342 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
|
2343 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
|
2344 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
|
2345 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
|
2346 '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
|
2347 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
|
2348 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
2349 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
|
2350 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
|
2351 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
|
2352 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
2353 # 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
|
2354 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
|
2355 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
|
2356 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
|
2357 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
|
2358 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
|
2359 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
|
2360 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
|
2361 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
2362 # 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
|
2363 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
|
2364 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
|
2365 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
|
2366 '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
|
2367 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
|
2368 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
2369 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
|
2370 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
|
2371 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
|
2372 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
2373 # 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
|
2374 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
|
2375 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
|
2376 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
|
2377 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
|
2378 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
|
2379 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
|
2380 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
|
2381 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
2382 # 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
|
2383 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
|
2384 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
|
2385 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
|
2386 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
|
2387 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
|
2388 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
|
2389 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
|
2390 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
|
2391 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
2392 # 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
|
2393 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
|
2394 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
|
2395 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
|
2396 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
|
2397 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
|
2398 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
|
2399 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
|
2400 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
2401 # 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
|
2402 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
|
2403 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
|
2404 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
|
2405 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
|
2406 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
|
2407 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
|
2408 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
|
2409 |
|
ff4ab763f47c
issue2551141 - roundup-admin returns no such class when restoring item with duplicate key
John Rouillard <rouilj@ieee.org>
parents:
6393
diff
changeset
|
2410 # 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
|
2411 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
|
2412 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
|
2413 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
|
2414 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
|
2415 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
|
2416 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
|
2417 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
|
2418 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
|
2419 |
|
7547
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2420 # test show_retired pragma three cases: |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2421 # no - no retired items |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2422 # only - only retired items |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2423 # both - all items |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2424 |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2425 # verify that user4 only is listed |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2426 self.admin=AdminTool() |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2427 with captured_output() as (out, err): |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2428 sys.argv=['main', '-i', self.dirname, '-P', |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2429 'show_retired=only', 'list', 'user'] |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2430 ret = self.admin.main() |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2431 out = out.getvalue().strip() |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2432 print(out) |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2433 expected="4: user1" |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2434 self.assertEqual(out, expected) |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2435 |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2436 # verify that all users are shown |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2437 self.admin=AdminTool() |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2438 with captured_output() as (out, err): |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2439 sys.argv=['main', '-i', self.dirname, '-P', |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2440 'show_retired=both', 'list', 'user'] |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2441 ret = self.admin.main() |
|
7548
793f4b63c538
Fix test where postgres returned items in different order
John Rouillard <rouilj@ieee.org>
parents:
7547
diff
changeset
|
2442 out_list = sorted(out.getvalue().strip().split("\n")) |
|
7547
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2443 print(out) |
|
7548
793f4b63c538
Fix test where postgres returned items in different order
John Rouillard <rouilj@ieee.org>
parents:
7547
diff
changeset
|
2444 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
|
2445 self.assertEqual(out_list, expected_list) |
|
7547
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2446 |
|
7549
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
2447 # verify that active users are shown |
|
7547
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2448 self.admin=AdminTool() |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2449 with captured_output() as (out, err): |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2450 sys.argv=['main', '-i', self.dirname, '-P', |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2451 'show_retired=no', 'list', 'user'] |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2452 ret = self.admin.main() |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2453 out = out.getvalue().strip() |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2454 print(out) |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2455 expected="1: admin\n 2: anonymous\n 3: user1" |
|
c8c4514f4c3e
issue685275 - show retired/unretire commands
John Rouillard <rouilj@ieee.org>
parents:
7546
diff
changeset
|
2456 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
|
2457 |
|
7549
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
2458 # test display headers for retired/active |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
2459 self.admin=AdminTool() |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
2460 with captured_output() as (out, err): |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
2461 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
|
2462 'display_header=yes', 'display', 'user3,user4'] |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
2463 ret = self.admin.main() |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
2464 out = out.getvalue().strip() |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
2465 print(out) |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
2466 self.assertIn("[user3 (active)]\n", out) |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
2467 self.assertIn( "[user4 (retired)]\n", out) |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
2468 |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
2469 # test that there are no headers |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
2470 self.admin=AdminTool() |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
2471 with captured_output() as (out, err): |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
2472 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
|
2473 ret = self.admin.main() |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
2474 out = out.getvalue().strip() |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
2475 print(out) |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
2476 self.assertNotIn("user3", out) |
|
73dfa9df9fb0
issue685275 - show retired/unretired items in roundup-admin
John Rouillard <rouilj@ieee.org>
parents:
7548
diff
changeset
|
2477 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
|
2478 |
| 6199 | 2479 def testTable(self): |
| 2480 ''' Note the tests will fail if you run this under pdb. | |
| 2481 the context managers capture the pdb prompts and this screws | |
| 2482 up the stdout strings with (pdb) prefixed to the line. | |
| 2483 ''' | |
| 2484 self.install_init() | |
| 2485 self.admin=AdminTool() | |
| 2486 | |
| 2487 with captured_output() as (out, err): | |
| 2488 sys.argv=['main', '-i', self.dirname, 'table' ] | |
| 2489 ret = self.admin.main() | |
| 2490 | |
| 2491 expected = 'Error: Not enough arguments supplied' | |
| 2492 | |
| 2493 out = out.getvalue().strip() | |
| 2494 print(out) | |
| 2495 print(expected) | |
| 2496 self.assertTrue(expected in out) | |
| 2497 #### | |
| 2498 | |
| 2499 self.admin=AdminTool() | |
| 2500 | |
| 2501 with captured_output() as (out, err): | |
| 2502 sys.argv=['main', '-i', self.dirname, 'table', | |
| 2503 'id,realname,username' ] | |
| 2504 ret = self.admin.main() | |
| 2505 | |
| 2506 expected = 'Error: no such class "id,realname,username"' | |
| 2507 | |
| 2508 out = out.getvalue().strip() | |
| 2509 print(out) | |
| 2510 print(expected) | |
| 2511 self.assertTrue(expected in out) | |
| 2512 | |
| 2513 #### | |
| 2514 self.admin=AdminTool() | |
| 2515 | |
| 2516 with captured_output() as (out, err): | |
| 2517 sys.argv=['main', '-i', self.dirname, 'table', 'user', | |
| 2518 'id,realname,username:4:3' ] | |
| 2519 ret = self.admin.main() | |
| 2520 expected = 'Error: "username:4:3" not name:width' | |
| 2521 | |
| 2522 out = out.getvalue().strip() | |
| 2523 print(out) | |
| 2524 print(expected) | |
| 2525 self.assertTrue(expected in out) | |
| 2526 | |
| 2527 #### | |
| 2528 self.admin=AdminTool() | |
| 2529 | |
| 2530 with captured_output() as (out, err): | |
| 2531 sys.argv=['main', '-i', self.dirname, 'table', 'user', | |
| 2532 'id,realname,title:4' ] | |
| 2533 ret = self.admin.main() | |
| 2534 expected = 'Error: user has no property "title"' | |
| 2535 | |
| 2536 out = out.getvalue().strip() | |
| 2537 print(out) | |
| 2538 print(expected) | |
| 2539 self.assertTrue(expected in out) | |
| 2540 | |
| 2541 #### | |
| 2542 self.admin=AdminTool() | |
| 2543 | |
| 2544 with captured_output() as (out, err): | |
| 2545 sys.argv=['main', '-i', self.dirname, 'table', 'user', | |
| 2546 'id,realname,username:' ] | |
| 2547 ret = self.admin.main() | |
| 2548 | |
| 2549 # note whitespace matters. trailing spaces on lines 1 and 2 | |
| 2550 expected = """Id Realname Username | |
| 2551 1 None admin | |
| 2552 2 None anonymou""" | |
| 2553 | |
| 2554 out = out.getvalue().strip() | |
| 2555 print(out) | |
| 2556 print(expected) | |
| 2557 self.assertEqual(out, expected) | |
| 2558 | |
| 2559 #### | |
| 2560 self.admin=AdminTool() | |
| 2561 | |
| 2562 with captured_output() as (out, err): | |
| 2563 sys.argv=['main', '-i', self.dirname, 'table', 'user', | |
| 2564 'id,realname,username' ] | |
| 2565 ret = self.admin.main() | |
| 2566 | |
| 2567 # note whitespace matters. trailing spaces on lines 1 and 2 | |
| 2568 expected = """Id Realname Username | |
| 2569 1 None admin | |
| 2570 2 None anonymous""" | |
| 2571 | |
| 2572 out = out.getvalue().strip() | |
| 2573 print(out) | |
| 2574 print(expected) | |
| 2575 self.assertEqual(out, expected) | |
| 2576 | |
| 2577 #### | |
| 2578 self.admin=AdminTool() | |
| 2579 | |
| 2580 with captured_output() as (out, err): | |
| 2581 sys.argv=['main', '-i', self.dirname, 'table', 'user', | |
| 2582 'id:4,realname:2,username:3' ] | |
| 2583 ret = self.admin.main() | |
| 2584 | |
| 2585 # note whitespace matters. trailing spaces on lines 1 and 2 | |
| 2586 expected = """Id Realname Username | |
| 2587 1 No adm | |
| 2588 2 No ano""" | |
| 2589 | |
| 2590 out = out.getvalue().strip() | |
| 2591 print(out) | |
| 2592 print(expected) | |
| 2593 self.assertEqual(out, expected) | |
| 2594 | |
|
6957
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2595 def testTemplates(self): |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2596 |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2597 self.install_init() |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2598 self.admin=AdminTool() |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2599 |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2600 with captured_output() as (out, err): |
|
6958
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
2601 # 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
|
2602 # 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
|
2603 sys.argv=['main', '-i', "zZzZ", 'templates' ] |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2604 ret = self.admin.main() |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2605 |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2606 out = out.getvalue().strip() |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2607 |
|
6958
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
2608 # 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
|
2609 for tracker in ['Name: classic\nPath:', |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2610 'Name: devel\nPath:', |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2611 'Name: jinja2\nPath:', |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2612 'Name: minimal\nPath:', |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2613 'Name: responsive\nPath:']: |
|
f924af12ef50
issue2551233 - create new roundup-admin command "templates"
John Rouillard <rouilj@ieee.org>
parents:
6430
diff
changeset
|
2614 self.assertIn(tracker, out) |
|
5713
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2615 |
|
6958
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
2616 with captured_output() as (out, err): |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
2617 # 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
|
2618 # directory to cause error if that changes |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
2619 sys.argv=['main', '-i', "zZzZ", 'templates', 'trace_search' ] |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
2620 ret = self.admin.main() |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
2621 |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
2622 out = out.getvalue().strip() |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
2623 |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
2624 expected = "/*\n" |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
2625 self.assertIn(expected, out) |
|
e54a2db40a9e
check trackers trace_search as well.
John Rouillard <rouilj@ieee.org>
parents:
6957
diff
changeset
|
2626 |
|
5713
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2627 class anydbmAdminTest(AdminTest, unittest.TestCase): |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2628 backend = 'anydbm' |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2629 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2630 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2631 @skip_mysql |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2632 class mysqlAdminTest(AdminTest, unittest.TestCase): |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2633 backend = 'mysql' |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2634 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2635 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2636 class sqliteAdminTest(AdminTest, unittest.TestCase): |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2637 backend = 'sqlite' |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2638 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2639 |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2640 @skip_postgresql |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2641 class postgresqlAdminTest(AdminTest, unittest.TestCase): |
|
95dfdbaf5aa6
A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff
changeset
|
2642 backend = 'postgresql' |
