@patch('os.path.exists')
    def test_default_keychain(self, exists_mock):
        expected = {
            'changes': {'default': '/path/to/chain.keychain'},
            'comment': '',
            'name': '/path/to/chain.keychain',
            'result': True
        }

        exists_mock.return_value = True
        get_default_mock = MagicMock(return_value='/path/to/other.keychain')
        set_mock = MagicMock(return_value='')
        with patch.dict(keychain.__salt__, {'keychain.get_default_keychain': get_default_mock,
                                            'keychain.set_default_keychain': set_mock}):
            out = keychain.default_keychain('/path/to/chain.keychain', 'system', 'frank')
            get_default_mock.assert_called_once_with('frank', 'system')
            set_mock.assert_called_once_with('/path/to/chain.keychain', 'system', 'frank')
            self.assertEqual(out, expected)
Test setting the default keychain
dataset/ETHPy150Open saltstack/salt/tests/unit/states/mac_keychain_test.py/KeychainTestCase.test_default_keychain