annotate test/test_admin.py @ 7650:4de48eadf5f4

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

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