Skip to content

Commit a3e04a0

Browse files
committed
Setup basic genconfig and updateconfig tests.
1 parent fd7bbad commit a3e04a0

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

test/test_admin.py

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,51 @@ def testFind(self):
275275
# so eval to real list so Equal can do a list compare
276276
self.assertEqual(sorted(eval(out)), ['1', '2'])
277277

278+
def testGenconfigUpdate(self):
279+
''' Note the tests will fail if you run this under pdb.
280+
the context managers capture the pdb prompts and this screws
281+
up the stdout strings with (pdb) prefixed to the line.
282+
'''
283+
import sys
284+
285+
self.admin=AdminTool()
286+
self.install_init()
287+
288+
with captured_output() as (out, err):
289+
sys.argv=['main', '-i', '_test_admin', 'genconfig']
290+
ret = self.admin.main()
291+
292+
out = out.getvalue().strip()
293+
print(out)
294+
expected = "Not enough arguments supplied"
295+
self.assertTrue(expected in out)
296+
297+
# Reopen the db closed by previous call
298+
self.admin=AdminTool()
299+
300+
with captured_output() as (out, err):
301+
sys.argv=['main', '-i', '_test_admin', 'genconfig', "foo"]
302+
ret = self.admin.main()
303+
304+
out = out.getvalue().strip()
305+
print(out)
306+
# FIXME get better successful test later.
307+
expected = ""
308+
self.assertTrue(expected in out)
309+
310+
# Reopen the db closed by previous call
311+
self.admin=AdminTool()
312+
313+
with captured_output() as (out, err):
314+
sys.argv=['main', '-i', '_test_admin', 'update', "foo2"]
315+
ret = self.admin.main()
316+
317+
out = out.getvalue().strip()
318+
print(out)
319+
# FIXME get better successful test later.
320+
expected = ""
321+
self.assertTrue(expected in out)
322+
278323
def testCliParse(self):
279324
''' Note the tests will fail if you run this under pdb.
280325
the context managers capture the pdb prompts and this screws
@@ -333,7 +378,6 @@ def testCliParse(self):
333378
'("help commands" for a list)')
334379
self.assertEqual(expected, out)
335380

336-
337381
# Reopen the db closed by previous call
338382
self.admin=AdminTool()
339383
# test for keyword=value check

0 commit comments

Comments
 (0)