/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-16 05:49:56 UTC
  • mto: This revision was merged to the branch mainline in revision 382.
  • Revision ID: teddy@recompile.se-20190316054956-ikjmjulma6jea5fa
mandos-ctl: Refactor and fix bug in tests.

* mandos-ctl (Test_check_option_syntax): Refactor and add more tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
954
954
    def check_option_syntax(self, options):
955
955
        check_option_syntax(self.parser, options)
956
956
 
957
 
    def test_actions_conflicts_with_verbose(self):
958
 
        for action, value in self.actions.items():
959
 
            options = self.parser.parse_args()
960
 
            setattr(options, action, value)
961
 
            options.verbose = True
 
957
    def test_actions_all_conflicts_with_verbose(self):
 
958
        for action, value in self.actions.items():
 
959
            options = self.parser.parse_args()
 
960
            setattr(options, action, value)
 
961
            options.all = True
 
962
            options.verbose = True
 
963
            with self.assertParseError():
 
964
                self.check_option_syntax(options)
 
965
 
 
966
    def test_actions_with_client_conflicts_with_verbose(self):
 
967
        for action, value in self.actions.items():
 
968
            options = self.parser.parse_args()
 
969
            setattr(options, action, value)
 
970
            options.verbose = True
 
971
            options.client = ["foo"]
962
972
            with self.assertParseError():
963
973
                self.check_option_syntax(options)
964
974
 
990
1000
            options.all = True
991
1001
            self.check_option_syntax(options)
992
1002
 
 
1003
    def test_any_action_is_ok_with_one_client(self):
 
1004
        for action, value in self.actions.items():
 
1005
            options = self.parser.parse_args()
 
1006
            setattr(options, action, value)
 
1007
            options.client = ["foo"]
 
1008
            self.check_option_syntax(options)
 
1009
 
 
1010
    def test_actions_except_is_enabled_are_ok_with_two_clients(self):
 
1011
        for action, value in self.actions.items():
 
1012
            if action == "is_enabled":
 
1013
                continue
 
1014
            options = self.parser.parse_args()
 
1015
            setattr(options, action, value)
 
1016
            options.client = ["foo", "barbar"]
 
1017
            self.check_option_syntax(options)
 
1018
 
993
1019
    def test_is_enabled_fails_without_client(self):
994
1020
        options = self.parser.parse_args()
995
1021
        options.is_enabled = True
996
1022
        with self.assertParseError():
997
1023
            self.check_option_syntax(options)
998
1024
 
999
 
    def test_is_enabled_works_with_one_client(self):
1000
 
        options = self.parser.parse_args()
1001
 
        options.is_enabled = True
1002
 
        options.client = ["foo"]
1003
 
        self.check_option_syntax(options)
1004
 
 
1005
1025
    def test_is_enabled_fails_with_two_clients(self):
1006
1026
        options = self.parser.parse_args()
1007
1027
        options.is_enabled = True