annotate test/test_admin.py @ 6199:e860c6a30508

admin.py testing. See previous checkin for admin.py. This got left out of the changeset apparently. test_admin.py: Add tests for get with bad node designator Add disabled test for HelpInitopts. Proper test TBD as valid result depends on the environment the test is run in. So making it robust it tricky. Add tests for set error cases. Add test for using set on class rather than designator Add new tests for table command
author John Rouillard <rouilj@ieee.org>
date Sat, 13 Jun 2020 00:19:38 -0400
parents 7458211ca6f3
children 95183d73ac64
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
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
8 import unittest, os, shutil, errno, sys, difflib, cgi, re
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
9
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
10 from roundup.admin import AdminTool
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
11
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
12 from . import db_test_base
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
5713
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
49 class AdminTest(object):
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
50
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
51 backend = None
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
52
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
53 def setUp(self):
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
54 self.dirname = '_test_admin'
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
55
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
56 def tearDown(self):
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
57 try:
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
58 shutil.rmtree(self.dirname)
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
59 except OSError as error:
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
60 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
61
6176
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
62 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
63 settings="mail_domain=example.com," +
6177
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
64 "mail_host=localhost," +
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
65 "tracker_web=http://test/," +
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
66 "rdbms_name=rounduptest," +
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
67 "rdbms_user=rounduptest," +
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
68 "rdbms_password=rounduptest," +
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
69 "rdbms_template=template0"
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
70 ):
6176
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
71 ''' 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
72 '''
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
73
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
74 admin=AdminTool()
6178
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
75 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
76
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
77 # 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
78 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
79 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
80 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
81 ret = admin.main()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
82 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
83
6178
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
84 # nuke any existing database (mysql/postgreql)
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
85 # 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
86 #tracker = instance.open(self.dirname)
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
87 #if tracker.exists():
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
88 # tracker.nuke()
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
89
6176
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
90 # 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
91 # 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
92 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
93 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
94 ret = admin.main()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
95 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
96
6178
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
97
6181
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
98 def testGet(self):
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
99 ''' 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
100 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
101 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
102 '''
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
103 import sys
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
104
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
105 self.install_init()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
106 self.admin=AdminTool()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
107
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
108 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
109 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
110 '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
111 ret = self.admin.main()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
112
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
113 out = out.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
114 print(out)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
115 self.assertEqual(out, '1')
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
116
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
117 self.admin=AdminTool()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
118 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
119 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
120 '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
121 'superseder=1']
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
122 ret = self.admin.main()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
123
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
124 self.assertEqual(ret, 0)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
125 out = out.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
126 print(out)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
127 self.assertEqual(out, '2')
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
128
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
129 self.admin=AdminTool()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
130 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
131 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
132 'issue2' ]
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
133 ret = self.admin.main()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
134
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
135 self.assertEqual(ret, 0)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
136 out = out.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
137 err = err.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
138 self.assertEqual(out, '2')
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
139 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
140
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
141 self.admin=AdminTool()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
142 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
143 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
144 'issue2' ]
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
145 ret = self.admin.main()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
146
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
147 self.assertEqual(ret, 0)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
148 out = out.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
149 err = err.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
150 self.assertEqual(out, "['1']")
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
151 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
152
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
153 self.admin=AdminTool()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
154 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
155 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
156 ret = self.admin.main()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
157
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
158 self.assertEqual(ret, 0)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
159 out = out.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
160 err = err.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
161 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
162 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
163
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
164 self.admin=AdminTool()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
165 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
166 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
167 ret = self.admin.main()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
168
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
169 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
170
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
171 self.assertEqual(ret, 1)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
172 out = out.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
173 err = err.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
174 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
175 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
176
6199
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
177 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
178 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
179 sys.argv=['main', '-i', self.dirname, 'get', 'title', 'issue']
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
180 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
181
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
182 expected_err = 'Error: "issue" not a node designator'
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
183
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
184 self.assertEqual(ret, 1)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
185 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
186 err = err.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
187 self.assertEqual(out.index(expected_err), 0)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
188 self.assertEqual(len(err), 0)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
189
5713
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
190 def testInit(self):
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
191 import sys
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
192 self.admin=AdminTool()
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
193 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
194 ret = self.admin.main()
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
195 print(ret)
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
196 self.assertTrue(ret == 0)
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
197 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
198 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
199
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
200 def testInitWithConfig_ini(self):
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
201 import sys
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
202 from roundup.configuration import CoreConfig
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
203 self.admin=AdminTool()
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
204 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
205 # create a config_ini.ini file in classic template
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
206 templates=self.admin.listTemplates()
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
207 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
208 config_ini_path = templates['classic']['path'] + '/config_ini.ini'
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
209 config_ini_file = open(config_ini_path, "w")
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
210 config_ini_file.write(config_ini_content)
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
211 config_ini_file.close()
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
212
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
213 try:
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
214 ret = self.admin.main()
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
215 finally:
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
216 try:
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
217 # ignore file not found
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
218 os.remove(config_ini_path)
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
219 except OSError as e: # FileNotFound exception under py3
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
220 if e.errno == 2:
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
221 pass
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
222 else:
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
223 raise
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
224
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
225 print(ret)
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
226 self.assertTrue(ret == 0)
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
227 self.assertTrue(os.path.isfile(self.dirname + "/config.ini"))
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
228 self.assertTrue(os.path.isfile(self.dirname + "/schema.py"))
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
229 config=CoreConfig(self.dirname)
b76be13e027e issue2551029: Jinja2 template install error.
John Rouillard <rouilj@ieee.org>
parents: 5713
diff changeset
230 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
231
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
232 def testFind(self):
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
233 ''' 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
234 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
235 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
236 '''
6177
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
237 import sys
6176
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
238
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
239 self.admin=AdminTool()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
240 self.install_init()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
241
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
242 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
243 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
244 '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
245 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
246
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
247 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
248 print(out)
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
249 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
250
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
251 self.admin=AdminTool()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
252 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
253 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
254 '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
255 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
256
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
257 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
258 print(out)
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
259 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
260
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
261 self.admin=AdminTool()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
262 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
263 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
264 'assignedto=1']
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
265 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
266
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
267 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
268 print(out)
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
269 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
270
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
271 # 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
272 self.admin=AdminTool()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
273 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
274 ''' 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
275 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
276 '''
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
277 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
278 'assignedto=1,2']
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
279 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
280
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
281 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
282 print(out)
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
283 # 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
284 # 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
285 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
286
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
287 # 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
288 self.admin=AdminTool()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
289 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
290 ''' 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
291 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
292 '''
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
293 sys.argv=['main', '-i', self.dirname, 'find', 'issue',
6176
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
294 'assignedto=admin,anonymous']
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
295 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
296
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
297 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
298 print(out)
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
299 # 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
300 # 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
301 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
302
6188
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
303 def testGenconfigUpdate(self):
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
304 ''' 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
305 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
306 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
307 '''
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
308 import sys, filecmp
6188
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
309
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
310 self.admin=AdminTool()
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
311 self.install_init()
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
312
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
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, 'genconfig']
6188
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
315 ret = self.admin.main()
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
316
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
317 out = out.getvalue().strip()
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
318 print(out)
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
319 expected = "Not enough arguments supplied"
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
320 self.assertTrue(expected in out)
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
321
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
322 # Reopen the db closed by previous call
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
323 self.admin=AdminTool()
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
324
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
325 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
326 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
327 self.dirname + "/config2.ini"]
6188
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
328 ret = self.admin.main()
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
329
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
330 out = out.getvalue().strip()
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
331 print(out)
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
332 # FIXME get better successful test later.
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
333 expected = ""
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
334 self.assertTrue(expected in out)
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
335 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
336 # 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
337 # 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
338 # to be customized.
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
339 #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
340 # self.dirname + "/config.ini"))
6188
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
341
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
342 # Reopen the db closed by previous call
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
343 self.admin=AdminTool()
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
344
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
345 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
346 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
347 self.dirname + "/foo2.ini"]
6188
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
348 ret = self.admin.main()
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
349
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
350 out = out.getvalue().strip()
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
351 print(out)
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
352 # FIXME get better successful test later.
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
353 expected = ""
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
354 self.assertTrue(expected in out)
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
355 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
356
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
357 # 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
358 # so filecmp passes.
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
359 normalize_file(self.dirname + "/foo2.ini",
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
360 [ '# Autogenerated at' ])
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
361 normalize_file(self.dirname + "/config.ini",
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
362 [ '# Autogenerated at' ])
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
363
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
364 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
365 self.dirname + "/foo2.ini"))
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
366
6188
32ebffbae49a Setup basic genconfig and updateconfig tests.
John Rouillard <rouilj@ieee.org>
parents: 6186
diff changeset
367
6186
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
368 def testCliParse(self):
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
369 ''' 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
370 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
371 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
372 '''
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
373 import sys
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
374
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
375 self.admin=AdminTool()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
376 self.install_init()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
377
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
378 # 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
379
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
380 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
381 ''' 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
382 report error.
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
383 '''
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
384 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
385 'assignedto=1']
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
386 ret = self.admin.main()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
387
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
388 out = out.getvalue().strip()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
389 print(out)
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
390 expected="[ '1' ]"
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
391 self.assertTrue(expected, out)
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
392
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
393 # 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
394 self.admin=AdminTool()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
395 # test multiple matches
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
396 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
397 ''' 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
398 report error.
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
399 '''
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
400 sys.argv=['main', '-i', self.dirname, 'f', 'issue',
6186
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
401 'assignedto']
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
402 ret = self.admin.main()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
403
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
404 out = out.getvalue().strip()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
405 print(out)
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
406 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
407 self.assertEqual(expected, out)
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
408
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
409 # 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
410 self.admin=AdminTool()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
411 # 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
412 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
413 ''' 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
414 report error.
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
415 '''
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
416 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
417 'assignedto']
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
418 ret = self.admin.main()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
419
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
420 out = out.getvalue().strip()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
421 print(out)
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
422 expected=('Unknown command "xyzzy" '
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
423 '("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
424 self.assertEqual(expected, out)
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
425
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
426 # 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
427 self.admin=AdminTool()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
428 # 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
429 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
430 ''' 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
431 report error.
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
432 '''
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
433 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
434 'assignedto']
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
435 ret = self.admin.main()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
436
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
437 out = out.getvalue().strip()
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
438 print(out)
81babf5a4494 Test for cli. Command partial match, Bad command, bad args.
John Rouillard <rouilj@ieee.org>
parents: 6181
diff changeset
439 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
440 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
441
6177
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
442 def testFilter(self):
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
443 ''' 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
444 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
445 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
446 '''
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
447 import sys
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
448
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
449 self.admin=AdminTool()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
450 self.install_init()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
451
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
452 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
453 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
454 'title="foo bar"', 'assignedto=admin' ]
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
455 ret = self.admin.main()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
456
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
457 out = out.getvalue().strip()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
458 print(out)
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
459 self.assertEqual(out, '1')
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
460
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
461 self.admin=AdminTool()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
462 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
463 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
464 'title="bar foo bar"', 'assignedto=anonymous' ]
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
465 ret = self.admin.main()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
466
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
467 out = out.getvalue().strip()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
468 print(out)
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
469 self.assertEqual(out, '2')
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
470
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
471
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
472 # Reopen the db closed by previous filter call
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
473 # test string - one results, one value, substring
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
474 self.admin=AdminTool()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
475 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
476 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
477 'username=admin']
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
478 ret = self.admin.main()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
479
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
480 out = out.getvalue().strip()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
481 print(out)
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
482 self.assertEqual(out, "['1']")
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
483
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
484 # Reopen the db closed by previous filter call
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
485 # test string - two results, two values, substring
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
486 self.admin=AdminTool()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
487 with captured_output() as (out, err):
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
488 ''' 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
489 so admin or anonymous
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
490 '''
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
491 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
492 'username=a,n']
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
493 ret = self.admin.main()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
494
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
495 out = out.getvalue().strip()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
496 print(out)
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
497 # out can be "['2', '1']" or "['1', '2']"
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
498 # 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
499 self.assertEqual(sorted(eval(out)), ['1', '2'])
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
500
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
501 # Reopen the db closed by previous filter call
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
502 # test string - one result, two values, substring
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
503 self.admin=AdminTool()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
504 with captured_output() as (out, err):
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
505 ''' 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
506 so anonymous
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
507 '''
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
508 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
509 'username=a,y']
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
510 ret = self.admin.main()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
511
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
512 out = out.getvalue().strip()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
513 print(out)
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
514 self.assertEqual(out, "['2']")
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
515
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
516 # Reopen the db closed by previous filter call
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
517 # test string - no results
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
518 self.admin=AdminTool()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
519 with captured_output() as (out, err):
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
520 ''' will return empty set as admin!=anonymous
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
521 '''
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
522 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
523 'username=admin,anonymous']
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
524 ret = self.admin.main()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
525
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
526 out = out.getvalue().strip()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
527 print(out)
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
528 self.assertEqual(out, "[]")
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
529
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
530 # Reopen the db closed by previous filter call
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
531 # test link using ids
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
532 self.admin=AdminTool()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
533 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
534 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
535 'assignedto=1,2']
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
536 ret = self.admin.main()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
537
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
538 out = out.getvalue().strip()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
539 print(out)
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
540 self.assertEqual(sorted(eval(out)), ['1', '2'])
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
541
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
542 # Reopen the db closed by previous filter call
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
543 # test link using names
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
544 self.admin=AdminTool()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
545 with captured_output() as (out, err):
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
546 ''' will return empty set as admin!=anonymous
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
547 '''
6189
7458211ca6f3 Use self.dirname, add testing for genconfig/updateconfig
John Rouillard <rouilj@ieee.org>
parents: 6188
diff changeset
548 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
549 'assignedto=admin,anonymous']
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
550 ret = self.admin.main()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
551
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
552 out = out.getvalue().strip()
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
553 print(out)
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
554 self.assertEqual(sorted(eval(out)), ['1', '2'])
41907e1f9c3f Fix postgres/mysql testing; test filter.
John Rouillard <rouilj@ieee.org>
parents: 6176
diff changeset
555
6199
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
556 def disabletestHelpInitopts(self):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
557
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
558 ''' Note the tests will fail if you run this under pdb.
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
559 the context managers capture the pdb prompts and this screws
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
560 up the stdout strings with (pdb) prefixed to the line.
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
561 '''
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
562 import sys
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
563
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
564 self.install_init()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
565 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
566
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
567 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
568 sys.argv=['main', '-i', self.dirname, 'help', 'initopts']
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
569 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
570
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
571 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
572 expected = [
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
573 'Templates: minimal, jinja2, classic, responsive, devel',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
574 'Back ends: anydbm, sqlite'
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
575 ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
576 print(out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
577 self.assertTrue(expected[0] in out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
578 self.assertTrue("Back ends:" in out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
579
6181
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
580 def testSet(self):
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
581 ''' 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
582 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
583 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
584 '''
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
585 import sys
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
586
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
587 self.install_init()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
588 self.admin=AdminTool()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
589
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
590 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
591 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
592 '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
593 ret = self.admin.main()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
594
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
595 out = out.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
596 print(out)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
597 self.assertEqual(out, '1')
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
598
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
599 self.admin=AdminTool()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
600 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
601 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
602 '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
603 ret = self.admin.main()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
604
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
605 out = out.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
606 print(out)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
607 self.assertEqual(out, '2')
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
608
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
609 self.admin=AdminTool()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
610 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
611 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
612 ret = self.admin.main()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
613
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
614 out = out.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
615 err = err.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
616 self.assertEqual(len(out), 0)
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
617 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
618
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
619 self.admin=AdminTool()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
620 with captured_output() as (out, err):
6199
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
621 sys.argv=['main', '-i', self.dirname, 'set', 'issue2',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
622 'tile="new title"']
6181
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
623 ret = self.admin.main()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
624
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
625 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
626
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
627 out = out.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
628 err = err.getvalue().strip()
49f599f187e1 Add tests for get and set, clean up Specification test.
John Rouillard <rouilj@ieee.org>
parents: 6178
diff changeset
629 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
630 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
631
6199
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
632 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
633 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
634 sys.argv=['main', '-i', self.dirname, 'set', 'issue2']
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
635 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
636
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
637 expected_err = "Error: Not enough arguments supplied"
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
638
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
639 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
640 err = err.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
641 self.assertEqual(out.index(expected_err), 0)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
642 self.assertEqual(len(err), 0)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
643
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
644
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
645 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
646 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
647 sys.argv=['main', '-i', self.dirname, 'set',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
648 'issue2,issue1,issue', "status=1" ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
649 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
650
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
651 expected_err = 'Error: "issue" not a node designator'
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
652
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
653 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
654 err = err.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
655 self.assertEqual(out.index(expected_err), 0)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
656 self.assertEqual(len(err), 0)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
657
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
658 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
659 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
660 sys.argv=['main', '-i', self.dirname, 'set',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
661 'issue2,issue1,user2', "status=1" ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
662 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
663
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
664 expected_err = "Error: 'status' is not a property of user"
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
665
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
666 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
667 err = err.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
668 print(out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
669 print(expected_err)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
670 print(err)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
671 self.assertEqual(out.index(expected_err), 0)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
672 self.assertEqual(len(err), 0)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
673
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
674 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
675 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
676 sys.argv=['main', '-i', self.dirname, 'set',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
677 'issue2,issue1,issue1000', "status=1" ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
678 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
679
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
680 expected_err = 'Error: no such issue 1000'
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
681
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
682 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
683 err = err.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
684 self.assertEqual(out.index(expected_err), 0)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
685 self.assertEqual(len(err), 0)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
686
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
687 def testSetOnClass(self):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
688 ''' Note the tests will fail if you run this under pdb.
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
689 the context managers capture the pdb prompts and this screws
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
690 up the stdout strings with (pdb) prefixed to the line.
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
691 '''
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
692 import sys
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
693
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
694 self.install_init()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
695
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
696 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
697 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
698 sys.argv=['main', '-i', self.dirname, 'create', 'issue',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
699 'title="foo bar"', 'assignedto=admin' ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
700 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
701
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
702 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
703 print(out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
704 self.assertEqual(out, '1')
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
705
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
706 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
707 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
708 sys.argv=['main', '-i', self.dirname, 'create', 'issue',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
709 'title="bar foo bar"', 'assignedto=anonymous' ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
710 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
711
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
712 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
713 print(out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
714 self.assertEqual(out, '2')
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
715
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
716 # Run this test in a separate test.
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
717 # It can cause a database timeout/resource
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
718 # unavailable error for anydbm when run with other tests.
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
719 # Not sure why.
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
720 # Set assignedto=2 for all issues
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
721 ## 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
722 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
723 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
724 sys.argv=['main', '-i', self.dirname, 'table', 'issue',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
725 'assignedto']
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
726 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
727
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
728 expected = "Assignedto\n1 \n2"
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
729 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
730 err = err.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
731 self.assertEqual(out, expected)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
732 self.assertEqual(len(err), 0)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
733 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
734 # do the set
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
735 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
736 sys.argv=['main', '-i', self.dirname, 'set', 'issue',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
737 'assignedto=2']
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
738 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
739
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
740 expected_err = ""
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
741
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
742 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
743 err = err.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
744 self.assertEqual(len(out), 0)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
745 self.assertEqual(len(err), 0)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
746
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
747 ## 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
748 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
749 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
750 sys.argv=['main', '-i', self.dirname, 'table', 'issue',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
751 'assignedto']
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
752 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
753
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
754 expected = "Assignedto\n2 \n2"
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
755 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
756 err = err.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
757 self.assertEqual(out, expected)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
758 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
759
6176
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
760 def testSpecification(self):
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
761 ''' 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
762 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
763 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
764 '''
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
765 import sys
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
766
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
767 self.install_init()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
768 self.admin=AdminTool()
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
769
6178
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
770 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
771 'alternate_addresses: <roundup.hyperdb.String>',
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
772 'realname: <roundup.hyperdb.String>',
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
773 'roles: <roundup.hyperdb.String>',
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
774 'organisation: <roundup.hyperdb.String>',
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
775 'queries: <roundup.hyperdb.Multilink to "query">',
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
776 'phone: <roundup.hyperdb.String>',
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
777 'address: <roundup.hyperdb.String>',
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
778 'timezone: <roundup.hyperdb.String>',
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
779 'password: <roundup.hyperdb.Password>',
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
780 ]
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
781
6176
d25638d1826c Add roundup-admin filter command; fix bad doc example; add tests
John Rouillard <rouilj@ieee.org>
parents: 5762
diff changeset
782 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
783 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
784 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
785
6178
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
786 outlist = out.getvalue().strip().split("\n")
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
787 print(outlist)
227c05ce2d85 Nuke database on install and fix specification test
John Rouillard <rouilj@ieee.org>
parents: 6177
diff changeset
788 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
789
6199
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
790 def testTable(self):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
791 ''' Note the tests will fail if you run this under pdb.
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
792 the context managers capture the pdb prompts and this screws
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
793 up the stdout strings with (pdb) prefixed to the line.
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
794 '''
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
795 import sys
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
796
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
797 self.install_init()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
798 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
799
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
800 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
801 sys.argv=['main', '-i', self.dirname, 'table' ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
802 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
803
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
804 expected = 'Error: Not enough arguments supplied'
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
805
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
806 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
807 print(out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
808 print(expected)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
809 self.assertTrue(expected in out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
810 ####
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
811
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
812 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
813
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
814 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
815 sys.argv=['main', '-i', self.dirname, 'table',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
816 'id,realname,username' ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
817 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
818
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
819 expected = 'Error: no such class "id,realname,username"'
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
820
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
821 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
822 print(out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
823 print(expected)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
824 self.assertTrue(expected in out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
825
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
826 ####
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
827 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
828
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
829 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
830 sys.argv=['main', '-i', self.dirname, 'table', 'user',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
831 'id,realname,username:4:3' ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
832 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
833 expected = 'Error: "username:4:3" not name:width'
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
834
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
835 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
836 print(out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
837 print(expected)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
838 self.assertTrue(expected in out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
839
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
840 ####
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
841 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
842
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
843 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
844 sys.argv=['main', '-i', self.dirname, 'table', 'user',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
845 'id,realname,title:4' ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
846 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
847 expected = 'Error: user has no property "title"'
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
848
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
849 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
850 print(out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
851 print(expected)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
852 self.assertTrue(expected in out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
853
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
854 ####
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
855 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
856
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
857 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
858 sys.argv=['main', '-i', self.dirname, 'table', 'user',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
859 'id,realname,username:' ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
860 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
861
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
862 # note whitespace matters. trailing spaces on lines 1 and 2
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
863 expected = """Id Realname Username
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
864 1 None admin
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
865 2 None anonymou"""
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
866
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
867 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
868 print(out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
869 print(expected)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
870 self.assertEqual(out, expected)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
871
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
872 ####
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
873 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
874
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
875 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
876 sys.argv=['main', '-i', self.dirname, 'table', 'user',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
877 'id,realname,username' ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
878 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
879
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
880 # note whitespace matters. trailing spaces on lines 1 and 2
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
881 expected = """Id Realname Username
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
882 1 None admin
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
883 2 None anonymous"""
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
884
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
885 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
886 print(out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
887 print(expected)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
888 self.assertEqual(out, expected)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
889
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
890 ####
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
891 self.admin=AdminTool()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
892
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
893 with captured_output() as (out, err):
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
894 sys.argv=['main', '-i', self.dirname, 'table', 'user',
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
895 'id:4,realname:2,username:3' ]
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
896 ret = self.admin.main()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
897
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
898 # note whitespace matters. trailing spaces on lines 1 and 2
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
899 expected = """Id Realname Username
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
900 1 No adm
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
901 2 No ano"""
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
902
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
903 out = out.getvalue().strip()
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
904 print(out)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
905 print(expected)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
906 self.assertEqual(out, expected)
e860c6a30508 admin.py testing.
John Rouillard <rouilj@ieee.org>
parents: 6189
diff changeset
907
5713
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
908
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
909 class anydbmAdminTest(AdminTest, unittest.TestCase):
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
910 backend = 'anydbm'
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
911
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
912
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
913 @skip_mysql
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
914 class mysqlAdminTest(AdminTest, unittest.TestCase):
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
915 backend = 'mysql'
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
916
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
917
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
918 class sqliteAdminTest(AdminTest, unittest.TestCase):
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
919 backend = 'sqlite'
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
920
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
921
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
922 @skip_postgresql
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
923 class postgresqlAdminTest(AdminTest, unittest.TestCase):
95dfdbaf5aa6 A basic set of tests for admin.py. Triggered by
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
924 backend = 'postgresql'

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