~frankban/charms/precise/juju-gui/improve-error-handling

« back to all changes in this revision

Viewing changes to server/guiserver/tests/test_manage.py

  • Committer: Francesco Banconi
  • Date: 2013-07-17 15:21:26 UTC
  • mto: This revision was merged to the branch mainline in revision 76.
  • Revision ID: francesco.banconi@canonical.com-20130717152126-p9oscvo7kfcwx64k
Renamed lib to guiserver.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
import mock
24
24
 
25
 
from lib import manage
26
 
 
27
 
 
28
 
@mock.patch('lib.manage.options')
 
25
from guiserver import manage
 
26
 
 
27
 
 
28
@mock.patch('guiserver.manage.options')
29
29
class TestAddDebug(unittest.TestCase):
30
30
 
31
31
    def test_debug_enabled(self, mock_options):
56
56
 
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')
61
61
 
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())
66
66
 
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')
71
71
 
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())
77
77
 
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')
82
82
 
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')
87
87
 
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')