def test_fstab(self): ''' List the content of the fstab ''' mock = MagicMock(return_value=False) with patch.object(os.path, 'isfile', mock): self.assertEqual(mount.fstab(), {}) mock = MagicMock(return_value=True) with patch.dict(mount.__grains__, {'kernel': ''}): with patch.object(os.path, 'isfile', mock): file_data = '\n'.join(['#', 'A B C D,E,F G H']) with patch('salt.utils.files.fopen', mock_open(read_data=file_data), create=True) as m: m.return_value.__iter__.return_value = file_data.splitlines( ) self.assertEqual( mount.fstab(), { 'B': { 'device': 'A', 'dump': 'G', 'fstype': 'C', 'opts': ['D', 'E', 'F'], 'pass': '******' } })
def test_vfstab(self): ''' List the content of the vfstab ''' mock = MagicMock(return_value=False) with patch.object(os.path, 'isfile', mock): self.assertEqual(mount.vfstab(), {}) mock = MagicMock(return_value=True) with patch.dict(mount.__grains__, {'kernel': 'SunOS'}): with patch.object(os.path, 'isfile', mock): file_data = '\n'.join([ '#', 'swap - /tmp tmpfs - yes size=2048m' ]) with patch('salt.utils.files.fopen', mock_open(read_data=file_data), create=True) as m: m.return_value.__iter__.return_value = file_data.splitlines( ) self.assertEqual( mount.fstab(), { '/tmp': { 'device': 'swap', 'device_fsck': '-', 'fstype': 'tmpfs', 'mount_at_boot': 'yes', 'opts': ['size=2048m'], 'pass_fsck': '-' } })
def test_vfstab(self): """ List the content of the vfstab """ mock = MagicMock(return_value=False) with patch.object(os.path, "isfile", mock): self.assertEqual(mount.vfstab(), {}) mock = MagicMock(return_value=True) with patch.dict(mount.__grains__, {"kernel": "SunOS"}): with patch.object(os.path, "isfile", mock): file_data = "\n".join(["#", "swap - /tmp tmpfs - yes size=2048m"]) with patch("salt.utils.fopen", mock_open(read_data=file_data), create=True) as m: m.return_value.__iter__.return_value = file_data.splitlines() self.assertEqual( mount.fstab(), { "/tmp": { "device": "swap", "device_fsck": "-", "fstype": "tmpfs", "mount_at_boot": "yes", "opts": ["size=2048m"], "pass_fsck": "-", } }, )
def test_fstab(self): """ List the content of the fstab """ mock = MagicMock(return_value=False) with patch.object(os.path, "isfile", mock): self.assertEqual(mount.fstab(), {}) mock = MagicMock(return_value=True) with patch.object(os.path, "isfile", mock): file_data = "\n".join(["#", "A B C D,E,F G H"]) with patch("salt.utils.fopen", mock_open(read_data=file_data), create=True) as m: m.return_value.__iter__.return_value = file_data.splitlines() self.assertEqual( mount.fstab(), {"B": {"device": "A", "dump": "G", "fstype": "C", "opts": ["D", "E", "F"], "pass": "******"}}, )
def test_fstab(self): ''' List the content of the fstab ''' mock = MagicMock(return_value=False) with patch.object(os.path, 'isfile', mock): self.assertEqual(mount.fstab(), {}) mock = MagicMock(return_value=True) with patch.object(os.path, 'isfile', mock): file_data = '\n'.join(['#', 'A B C D,E,F G H']) with patch('salt.utils.fopen', mock_open(read_data=file_data), create=True) as m: m.return_value.__iter__.return_value = file_data.splitlines() self.assertEqual(mount.fstab(), {'B': {'device': 'A', 'dump': 'G', 'fstype': 'C', 'opts': ['D', 'E', 'F'], 'pass': '******'}})
def test_fstab(): """ List the content of the fstab """ mock = MagicMock(return_value=False) with patch.object(os.path, "isfile", mock): assert mount.fstab() == {} file_data = "\n".join(["#", "A B C D,E,F G H"]) mock = MagicMock(return_value=True) with patch.dict(mount.__grains__, {"kernel": ""}), patch.object( os.path, "isfile", mock), patch("salt.utils.files.fopen", mock_open(read_data=file_data)): fstab = mount.fstab() assert fstab == { "B": { "device": "A", "dump": "G", "fstype": "C", "opts": ["D", "E", "F"], "pass": "******", } }, fstab