annotate test/test_admin.py @ 8580:5cba36e42b8f

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

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