コード例 #1
0
ファイル: test_mac_xattr.py プロジェクト: vindir/salt
 def test_write(self):
     '''
     Test writing a specific attribute to a file
     '''
     mock_cmd = MagicMock(return_value='squarepants')
     with patch.object(xattr, 'read', mock_cmd):
         self.assertTrue(
             xattr.write('/path/to/file', 'spongebob', 'squarepants'))
コード例 #2
0
def test_write():
    """
    Test writing a specific attribute to a file
    """
    mock_cmd = MagicMock(return_value="squarepants")
    with patch.object(xattr, "read", mock_cmd), patch(
            "salt.utils.mac_utils.execute_return_success",
            MagicMock(return_value=True)):
        assert xattr.write("/path/to/file", "spongebob", "squarepants")
コード例 #3
0
ファイル: mac_xattr_test.py プロジェクト: bryson/salt
 def test_write(self):
     '''
     Test writing a specific attribute to a file
     '''
     mock_cmd = MagicMock(return_value='squarepants')
     with patch.object(xattr, 'read', mock_cmd):
         self.assertTrue(xattr.write('/path/to/file',
                                     'spongebob',
                                     'squarepants'))
コード例 #4
0
ファイル: test_mac_xattr.py プロジェクト: MalloZup/salt-2
 def test_write(self):
     '''
     Test writing a specific attribute to a file
     '''
     mock_cmd = MagicMock(return_value='squarepants')
     with patch.object(xattr, 'read', mock_cmd), \
             patch('salt.utils.mac_utils.execute_return_success',
                   MagicMock(return_value=True)):
         self.assertTrue(
             xattr.write('/path/to/file', 'spongebob', 'squarepants'))
コード例 #5
0
ファイル: mac_xattr_test.py プロジェクト: HowardMei/saltstack
    def test_write_attrs(self):
        '''
            Test writing a specific attribute to a file
        '''
        expected = "out"
        mock = MagicMock(return_value=expected)
        with patch.dict(xattr.__salt__, {'cmd.run': mock}):
            out = xattr.write('/path/to/file', 'com.attr', 'value')

            mock.assert_called_once_with('xattr -w  "com.attr" "value" "/path/to/file"')
            self.assertEqual(out, expected)
コード例 #6
0
ファイル: mac_xattr_test.py プロジェクト: zhugehui9527/salt
    def test_write_attrs(self):
        '''
            Test writing a specific attribute to a file
        '''
        expected = "out"
        mock = MagicMock(return_value=expected)
        with patch.dict(xattr.__salt__, {'cmd.run': mock}):
            out = xattr.write('/path/to/file', 'com.attr', 'value')

            mock.assert_called_once_with(
                'xattr -w  "com.attr" "value" "/path/to/file"')
            self.assertEqual(out, expected)