comparison test/test_admin.py @ 7543:fc9daba984c0

- issue2551103 - add pragma 'display_protected' to roundup-admin. If setting is true, print protected attributes like id, activity, actor... when using display or specification subcommands.
author John Rouillard <rouilj@ieee.org>
date Thu, 13 Jul 2023 23:47:43 -0400
parents 312d52305583
children 534f8bdb8f94
comparison
equal deleted inserted replaced
7542:3b67f0e7fe48 7543:fc9daba984c0
1028 1028
1029 out = out.getvalue().strip().split('\n') 1029 out = out.getvalue().strip().split('\n')
1030 1030
1031 print(ret) 1031 print(ret)
1032 expected = 'Error: Internal error: pragma can not handle values of type: float' 1032 expected = 'Error: Internal error: pragma can not handle values of type: float'
1033 self.assertIn(expected, out)
1034
1035
1036 # -----
1037 inputs = iter(["pragma display_protected=yes",
1038 "display user1",
1039 "quit"])
1040 AdminTool.my_input = lambda _self, _prompt: next(inputs)
1041
1042 self.install_init()
1043 self.admin=AdminTool()
1044 sys.argv=['main', '-i', self.dirname]
1045
1046 with captured_output() as (out, err):
1047 ret = self.admin.main()
1048
1049 out = out.getvalue().strip()
1050
1051 print(ret)
1052 expected = '\n*creation: '
1033 self.assertIn(expected, out) 1053 self.assertIn(expected, out)
1034 1054
1035 # ----- 1055 # -----
1036 AdminTool.my_input = orig_input 1056 AdminTool.my_input = orig_input
1037 1057
1477 'phone: <roundup.hyperdb.String>', 1497 'phone: <roundup.hyperdb.String>',
1478 'address: <roundup.hyperdb.String>', 1498 'address: <roundup.hyperdb.String>',
1479 'timezone: <roundup.hyperdb.String>', 1499 'timezone: <roundup.hyperdb.String>',
1480 'password: <roundup.hyperdb.Password>', 1500 'password: <roundup.hyperdb.Password>',
1481 ] 1501 ]
1502
1482 1503
1483 with captured_output() as (out, err): 1504 with captured_output() as (out, err):
1484 sys.argv=['main', '-i', self.dirname, 'specification', 'user'] 1505 sys.argv=['main', '-i', self.dirname, 'specification', 'user']
1485 ret = self.admin.main() 1506 ret = self.admin.main()
1486 1507
1487 outlist = out.getvalue().strip().split("\n") 1508 outlist = out.getvalue().strip().split("\n")
1488 print(outlist) 1509 print(outlist)
1489 self.assertEqual(sorted(outlist), sorted(spec)) 1510 self.assertEqual(sorted(outlist), sorted(spec))
1511
1512 # -----
1513 inputs = iter(["pragma display_protected=1", "spec user", "quit"])
1514 AdminTool.my_input = lambda _self, _prompt: next(inputs)
1515
1516 self.install_init()
1517 self.admin=AdminTool()
1518 sys.argv=['main', '-i', self.dirname]
1519
1520 with captured_output() as (out, err):
1521 ret = self.admin.main()
1522
1523 # strip greeting and help text lines
1524 outlist = out.getvalue().strip().split('\n')[2:]
1525
1526 protected = [ 'id: <roundup.hyperdb.String>',
1527 'creation: <roundup.hyperdb.Date>',
1528 'activity: <roundup.hyperdb.Date>',
1529 'creator: <roundup.hyperdb.Link to "user">',
1530 'actor: <roundup.hyperdb.Link to "user">']
1531 print(outlist)
1532 self.assertEqual(sorted(outlist), sorted(spec + protected))
1490 1533
1491 def testRetireRestore(self): 1534 def testRetireRestore(self):
1492 ''' Note the tests will fail if you run this under pdb. 1535 ''' Note the tests will fail if you run this under pdb.
1493 the context managers capture the pdb prompts and this screws 1536 the context managers capture the pdb prompts and this screws
1494 up the stdout strings with (pdb) prefixed to the line. 1537 up the stdout strings with (pdb) prefixed to the line.

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