コード例 #1
0
ファイル: test_mac_defaults.py プロジェクト: cldeluna/salt
    def test_write_boolean(self):
        '''
            Test writing a default setting with a boolean
        '''
        expected = {
            'changes': {
                'written': 'com.apple.something Key is set to True'
            },
            'comment': '',
            'name': 'Key',
            'result': True
        }

        read_mock = MagicMock(return_value='0')
        write_mock = MagicMock(return_value={'retcode': 0})
        with patch.dict(macdefaults.__salt__, {
                'macdefaults.read': read_mock,
                'macdefaults.write': write_mock
        }):
            out = macdefaults.write('Key',
                                    'com.apple.something',
                                    True,
                                    vtype='boolean')
            read_mock.assert_called_once_with('com.apple.something', 'Key',
                                              None)
            write_mock.assert_called_once_with('com.apple.something', 'Key',
                                               True, 'boolean', None)
            self.assertEqual(out, expected)
コード例 #2
0
ファイル: test_mac_defaults.py プロジェクト: cldeluna/salt
    def test_write(self):
        '''
            Test writing a default setting
        '''
        expected = {
            'changes': {
                'written':
                'com.apple.CrashReporter DialogType is set to Server'
            },
            'comment': '',
            'name': 'DialogType',
            'result': True
        }

        read_mock = MagicMock(return_value='Local')
        write_mock = MagicMock(return_value={'retcode': 0})
        with patch.dict(macdefaults.__salt__, {
                'macdefaults.read': read_mock,
                'macdefaults.write': write_mock
        }):
            out = macdefaults.write('DialogType', 'com.apple.CrashReporter',
                                    'Server')
            read_mock.assert_called_once_with('com.apple.CrashReporter',
                                              'DialogType', None)
            write_mock.assert_called_once_with('com.apple.CrashReporter',
                                               'DialogType', 'Server',
                                               'string', None)
            self.assertEqual(out, expected)
コード例 #3
0
ファイル: test_mac_defaults.py プロジェクト: cldeluna/salt
    def test_write_integer_match(self):
        '''
            Test writing a default setting with a integer that is already set to the same value
        '''
        expected = {
            'changes': {},
            'comment': 'com.apple.something Key is already set to 1337',
            'name': 'Key',
            'result': True
        }

        read_mock = MagicMock(return_value='1337')
        write_mock = MagicMock(return_value={'retcode': 0})
        with patch.dict(macdefaults.__salt__, {
                'macdefaults.read': read_mock,
                'macdefaults.write': write_mock
        }):
            out = macdefaults.write('Key',
                                    'com.apple.something',
                                    1337,
                                    vtype='integer')
            read_mock.assert_called_once_with('com.apple.something', 'Key',
                                              None)
            assert not write_mock.called
            self.assertEqual(out, expected)
コード例 #4
0
ファイル: mac_defaults_test.py プロジェクト: bryson/salt
    def test_write_boolean_match(self):
        '''
            Test writing a default setting with a boolean that is already set to the same value
        '''
        expected = {
            'changes': {},
            'comment': 'com.apple.something Key is already set to YES',
            'name': 'Key',
            'result': True
        }

        read_mock = MagicMock(return_value='1')
        write_mock = MagicMock(return_value={'retcode': 0})
        with patch.dict(macdefaults.__salt__, {'macdefaults.read': read_mock,
                                               'macdefaults.write': write_mock}):
            out = macdefaults.write('Key', 'com.apple.something', 'YES', vtype='boolean')
            read_mock.assert_called_once_with('com.apple.something', 'Key', None)
            assert not write_mock.called
            self.assertEqual(out, expected)
コード例 #5
0
ファイル: mac_defaults_test.py プロジェクト: bryson/salt
    def test_write_boolean(self):
        '''
            Test writing a default setting with a boolean
        '''
        expected = {
            'changes': {'written': 'com.apple.something Key is set to True'},
            'comment': '',
            'name': 'Key',
            'result': True
        }

        read_mock = MagicMock(return_value='0')
        write_mock = MagicMock(return_value={'retcode': 0})
        with patch.dict(macdefaults.__salt__, {'macdefaults.read': read_mock,
                                               'macdefaults.write': write_mock}):
            out = macdefaults.write('Key', 'com.apple.something', True, vtype='boolean')
            read_mock.assert_called_once_with('com.apple.something', 'Key', None)
            write_mock.assert_called_once_with('com.apple.something', 'Key', True, 'boolean', None)
            self.assertEqual(out, expected)
コード例 #6
0
ファイル: mac_defaults_test.py プロジェクト: bryson/salt
    def test_write_set(self):
        '''
            Test writing a default setting that is already set
        '''
        expected = {
            'changes': {},
            'comment': 'com.apple.CrashReporter DialogType is already set to Server',
            'name': 'DialogType',
            'result': True
        }

        read_mock = MagicMock(return_value='Server')
        write_mock = MagicMock(return_value={'retcode': 0})
        with patch.dict(macdefaults.__salt__, {'macdefaults.read': read_mock,
                                               'macdefaults.write': write_mock}):
            out = macdefaults.write('DialogType', 'com.apple.CrashReporter', 'Server')
            read_mock.assert_called_once_with('com.apple.CrashReporter', 'DialogType', None)
            assert not write_mock.called
            self.assertEqual(out, expected)