Ejemplo n.º 1
0
 def test_read(self):
     '''
     Test reading a specific attribute from a file
     '''
     with patch('salt.utils.mac_utils.execute_return_result',
                MagicMock(return_value='expected results')):
         self.assertEqual(xattr.read('/path/to/file', 'com.attr'),
                          'expected results')
Ejemplo n.º 2
0
def test_read():
    """
    Test reading a specific attribute from a file
    """
    with patch(
            "salt.utils.mac_utils.execute_return_result",
            MagicMock(return_value="expected results"),
    ):
        assert xattr.read("/path/to/file", "com.attr") == "expected results"
Ejemplo n.º 3
0
 def test_read_hex(self):
     '''
     Test reading a specific attribute from a file
     '''
     with patch.object(salt.utils.mac_utils, 'execute_return_result',
                       MagicMock(return_value='expected results')) as mock:
         self.assertEqual(xattr.read('/path/to/file', 'com.attr', True),
                          'expected results')
         mock.assert_called_once_with(
             'xattr -p -x "com.attr" "/path/to/file"')
Ejemplo n.º 4
0
    def test_read_attrs_hex(self):
        '''
            Test reading a specific attribute from a file with hex
        '''
        expected = "out"
        mock = MagicMock(return_value=expected)
        with patch.dict(xattr.__salt__, {'cmd.run': mock}):
            out = xattr.read('/path/to/file', 'com.attr', True)

            mock.assert_called_once_with('xattr -p -x "com.attr" "/path/to/file"')
            self.assertEqual(out, expected)
Ejemplo n.º 5
0
 def test_read_hex(self):
     '''
     Test reading a specific attribute from a file
     '''
     with patch.object(salt.utils.mac_utils, 'execute_return_result',
                       MagicMock(return_value='expected results')) as mock:
         self.assertEqual(
             xattr.read('/path/to/file', 'com.attr', **{'hex': True}),
             'expected results'
         )
         mock.assert_called_once_with(
             ['xattr', '-p', '-x', 'com.attr', '/path/to/file'])
Ejemplo n.º 6
0
    def test_read_attrs_hex(self):
        '''
            Test reading a specific attribute from a file with hex
        '''
        expected = "out"
        mock = MagicMock(return_value=expected)
        with patch.dict(xattr.__salt__, {'cmd.run': mock}):
            out = xattr.read('/path/to/file', 'com.attr', True)

            mock.assert_called_once_with(
                'xattr -p -x "com.attr" "/path/to/file"')
            self.assertEqual(out, expected)
Ejemplo n.º 7
0
def test_read_hex():
    """
    Test reading a specific attribute from a file
    """
    with patch.object(
            salt.utils.mac_utils,
            "execute_return_result",
            MagicMock(return_value="expected results"),
    ) as mock:
        assert (xattr.read("/path/to/file", "com.attr",
                           **{"hex": True}) == "expected results")
        mock.assert_called_once_with(
            ["xattr", "-p", "-x", "com.attr", "/path/to/file"])
Ejemplo n.º 8
0
 def test_read(self):
     '''
     Test reading a specific attribute from a file
     '''
     self.assertEqual(xattr.read('/path/to/file', 'com.attr'),
                      'expected results')
Ejemplo n.º 9
0
 def test_read(self):
     '''
     Test reading a specific attribute from a file
     '''
     self.assertEqual(xattr.read('/path/to/file', 'com.attr'),
                      'expected results')