Exemplo n.º 1
0
 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'))
Exemplo n.º 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")
Exemplo n.º 3
0
 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'))
Exemplo n.º 4
0
 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'))
Exemplo n.º 5
0
    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)
Exemplo n.º 6
0
    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)