annotate test/test_admin.py @ 7803:2746337ded4c

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

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