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')
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"
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"')
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)
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'])
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)
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"])
def test_read(self): ''' Test reading a specific attribute from a file ''' self.assertEqual(xattr.read('/path/to/file', 'com.attr'), 'expected results')
def test_read(self): ''' Test reading a specific attribute from a file ''' self.assertEqual(xattr.read('/path/to/file', 'com.attr'), 'expected results')