Esempio n. 1
0
 def test_failure_invalid_type(self):
     # The validation fails if the arg value is not a string.
     with mock.patch("guiserver.manage.options", {"arg1": 42}):
         with self.assert_sysexit(self.error.format("arg1")):
             manage._validate_required("arg1")
Esempio n. 2
0
 def test_failure_missing(self):
     # The validation fails if the value is missing.
     with mock.patch("guiserver.manage.options", {"arg1": None}):
         with self.assert_sysexit(self.error.format("arg1")):
             manage._validate_required("arg1")
Esempio n. 3
0
 def test_failure_empty(self):
     # The validation fails if the stripped value is an empty string.
     with mock.patch("guiserver.manage.options", {"arg1": " "}):
         with self.assert_sysexit(self.error.format("arg1")):
             manage._validate_required("arg1")
Esempio n. 4
0
 def test_success_multiple_args(self):
     # The validation passes for multiple args.
     options = {"arg1": "value1", "arg2": "value2"}
     with mock.patch("guiserver.manage.options", options):
         manage._validate_required(*options.keys())
Esempio n. 5
0
 def test_failure_multiple_args(self):
     # The validation fails if one of the arg values is an empty string.
     options = {"arg1": "value1", "arg2": ""}
     with mock.patch("guiserver.manage.options", options):
         with self.assert_sysexit(self.error.format("arg2")):
             manage._validate_required(*options.keys())
Esempio n. 6
0
 def test_failure_invalid_type(self):
     # The validation fails if the arg value is not a string.
     with mock.patch('guiserver.manage.options', {'arg1': 42}):
         with self.assert_sysexit(self.error.format('arg1')):
             manage._validate_required('arg1')
Esempio n. 7
0
 def test_success(self):
     # The validation passes if the args are correctly found.
     with mock.patch("guiserver.manage.options", {"arg1": "value1"}):
         manage._validate_required("arg1")
Esempio n. 8
0
 def test_failure_missing(self):
     # The validation fails if the value is missing.
     with mock.patch('guiserver.manage.options', {'arg1': None}):
         with self.assert_sysexit(self.error.format('arg1')):
             manage._validate_required('arg1')
Esempio n. 9
0
 def test_failure_empty(self):
     # The validation fails if the stripped value is an empty string.
     with mock.patch('guiserver.manage.options', {'arg1': ' '}):
         with self.assert_sysexit(self.error.format('arg1')):
             manage._validate_required('arg1')
Esempio n. 10
0
 def test_success_multiple_args(self):
     # The validation passes for multiple args.
     options = {'arg1': 'value1', 'arg2': 'value2'}
     with mock.patch('guiserver.manage.options', options):
         manage._validate_required(*options.keys())
Esempio n. 11
0
 def test_failure_multiple_args(self):
     # The validation fails if one of the arg values is an empty string.
     options = {'arg1': 'value1', 'arg2': ''}
     with mock.patch('guiserver.manage.options', options):
         with self.assert_sysexit(self.error.format('arg2')):
             manage._validate_required(*options.keys())
Esempio n. 12
0
 def test_success(self):
     # The validation passes if the args are correctly found.
     with mock.patch('guiserver.manage.options', {'arg1': 'value1'}):
         manage._validate_required('arg1')
Esempio n. 13
0
 def test_failure_empty(self):
     # The validation fails if the stripped value is an empty string.
     with mock.patch('guiserver.manage.options', {'arg1': ' '}):
         with self.assert_sysexit(self.error.format('arg1')):
             manage._validate_required('arg1')
Esempio n. 14
0
 def test_failure_multiple_args(self):
     # The validation fails if one of the arg values is an empty string.
     options = {'arg1': 'value1', 'arg2': ''}
     with mock.patch('guiserver.manage.options', options):
         with self.assert_sysexit(self.error.format('arg2')):
             manage._validate_required(*options.keys())
Esempio n. 15
0
 def test_success_multiple_args(self):
     # The validation passes for multiple args.
     options = {'arg1': 'value1', 'arg2': 'value2'}
     with mock.patch('guiserver.manage.options', options):
         manage._validate_required(*options.keys())
Esempio n. 16
0
 def test_success(self):
     # The validation passes if the args are correctly found.
     with mock.patch('guiserver.manage.options', {'arg1': 'value1'}):
         manage._validate_required('arg1')