annotate test/test_admin.py @ 8435:1a93dc58f975

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

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