25
from lib import manage
28
@mock.patch('lib.manage.options')
25
from guiserver import manage
28
@mock.patch('guiserver.manage.options')
29
29
class TestAddDebug(unittest.TestCase):
31
31
def test_debug_enabled(self, mock_options):
57
57
def test_success(self):
58
58
# The validation passes if the args are correctly found.
59
with mock.patch('lib.manage.options', {'arg1': 'value1'}):
59
with mock.patch('guiserver.manage.options', {'arg1': 'value1'}):
60
60
manage._validate_required('arg1')
62
62
def test_success_multiple_args(self):
63
63
options = {'arg1': 'value1', 'arg2': 'value2'}
64
with mock.patch('lib.manage.options', options):
64
with mock.patch('guiserver.manage.options', options):
65
65
manage._validate_required(*options.keys())
67
67
def test_failure(self):
68
with mock.patch('lib.manage.options', {'arg1': ''}):
68
with mock.patch('guiserver.manage.options', {'arg1': ''}):
69
69
with self.assert_sysexit('arg1'):
70
70
manage._validate_required('arg1')
72
72
def test_failure_multiple_args(self):
73
73
options = {'arg1': 'value1', 'arg2': ''}
74
with mock.patch('lib.manage.options', options):
74
with mock.patch('guiserver.manage.options', options):
75
75
with self.assert_sysexit('arg2'):
76
76
manage._validate_required(*options.keys())
78
78
def test_failure_missing(self):
79
with mock.patch('lib.manage.options', {'arg1': None}):
79
with mock.patch('guiserver.manage.options', {'arg1': None}):
80
80
with self.assert_sysexit('arg1'):
81
81
manage._validate_required('arg1')
83
83
def test_failure_empty(self):
84
with mock.patch('lib.manage.options', {'arg1': ' '}):
84
with mock.patch('guiserver.manage.options', {'arg1': ' '}):
85
85
with self.assert_sysexit('arg1'):
86
86
manage._validate_required('arg1')
88
88
def test_failure_invalid_type(self):
89
with mock.patch('lib.manage.options', {'arg1': 42}):
89
with mock.patch('guiserver.manage.options', {'arg1': 42}):
90
90
with self.assert_sysexit('arg1'):
91
91
manage._validate_required('arg1')