/mandos/release

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/release

« back to all changes in this revision

Viewing changes to mandos-ctl

  • Committer: Teddy Hogeborn
  • Date: 2019-03-02 02:43:59 UTC
  • mto: (237.7.594 trunk)
  • mto: This revision was merged to the branch mainline in revision 382.
  • Revision ID: teddy@recompile.se-20190302024359-x3p601t67ki2h2mn
mandos-ctl: Refactor

* mandos-ctl (Test_TableOfClients): Don't test rows() method; test
                                    string representation directly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
647
647
            },
648
648
        ]
649
649
    def test_short_header(self):
650
 
        rows = TableOfClients(self.clients, self.keywords,
651
 
                              self.tablewords).rows()
652
 
        expected_rows = [
653
 
            "X  Yy",
654
 
            "x1 y1",
655
 
            "x2 y2"]
656
 
        self.assertEqual(rows, expected_rows)
 
650
        text = str(TableOfClients(self.clients, self.keywords,
 
651
                                  self.tablewords))
 
652
        expected_text = """
 
653
X  Yy
 
654
x1 y1
 
655
x2 y2
 
656
"""[1:-1]
 
657
        self.assertEqual(text, expected_text)
657
658
    def test_booleans(self):
658
659
        keywords = ["Bool", "NonDbusBoolean"]
659
 
        rows = TableOfClients(self.clients, keywords,
660
 
                              self.tablewords).rows()
661
 
        expected_rows = [
662
 
            "A D-BUS Boolean A Non-D-BUS Boolean",
663
 
            "No              False              ",
664
 
            "Yes             True               ",
665
 
        ]
666
 
        self.assertEqual(rows, expected_rows)
 
660
        text = str(TableOfClients(self.clients, keywords,
 
661
                                  self.tablewords))
 
662
        expected_text = """
 
663
A D-BUS Boolean A Non-D-BUS Boolean
 
664
No              False              
 
665
Yes             True               
 
666
"""[1:-1]
 
667
        self.assertEqual(text, expected_text)
667
668
    def test_milliseconds_detection(self):
668
669
        keywords = ["Integer", "Timeout", "Interval", "ApprovalDelay",
669
670
                    "ApprovalDuration", "ExtendedTimeout"]
670
 
        rows = TableOfClients(self.clients, keywords,
671
 
                              self.tablewords).rows()
672
 
        expected_rows = ("""
 
671
        text = str(TableOfClients(self.clients, keywords,
 
672
                                  self.tablewords))
 
673
        expected_text = """
673
674
An Integer Timedelta 1 Timedelta 2 Timedelta 3 Timedelta 4 Timedelta 5
674
675
0          00:00:00    00:00:01    00:00:02    00:00:03    00:00:04   
675
676
1          1T02:03:05  1T02:03:06  1T02:03:07  1T02:03:08  1T02:03:09 
676
 
"""
677
 
        ).splitlines()[1:]
678
 
        self.assertEqual(rows, expected_rows)
 
677
"""[1:-1]
 
678
        self.assertEqual(text, expected_text)
679
679
    def test_empty_and_long_string_values(self):
680
680
        keywords = ["String"]
681
 
        rows = TableOfClients(self.clients, keywords,
682
 
                              self.tablewords).rows()
683
 
        expected_rows = ("""
 
681
        text = str(TableOfClients(self.clients, keywords,
 
682
                                  self.tablewords))
 
683
        expected_text = """
684
684
A String                                                                                                                                                                                                                                                                                                                                  
685
685
                                                                                                                                                                                                                                                                                                                                          
686
686
A huge string which will not fit,A huge string which will not fit,A huge string which will not fit,A huge string which will not fit,A huge string which will not fit,A huge string which will not fit,A huge string which will not fit,A huge string which will not fit,A huge string which will not fit,A huge string which will not fit,
687
 
"""
688
 
        ).splitlines()[1:]
689
 
        self.assertEqual(rows, expected_rows)
 
687
"""[1:-1]
 
688
        self.assertEqual(text, expected_text)
690
689
 
691
690
 
692
691