def test_activate_exists_success(self, mock_mkdir, pread2): """ Test that activeate MPDev works if directory exists """ mock_mkdir.side_effect = [OSError(errno.EEXIST, "Directory exists")] mpath_dmp.activate_MPdev("sid", "dst") pread2.assert_called_with(['ln', '-sf', "dst", os.path.join(mpath_dmp.MP_INUSEDIR, "sid")])
def test_activate_no_exception(self, mock_mkdir, pread2): """ Test that activate MPDev works if directory does not exist """ mpath_dmp.activate_MPdev("sid", "dst") pread2.assert_called_with( ['ln', '-sf', "dst", os.path.join(mpath_dmp.MP_INUSEDIR, "sid")])
def test_activate_permission_denied(self, mock_mkdir): """ Test that activeate MPDev works if mkdir returns permission denied """ mock_mkdir.side_effect = [OSError(errno.EPERM, "Permission denied")] with self.assertRaises(OSError) as context: mpath_dmp.activate_MPdev("sid", "dst") self.assertEqual(errno.EPERM, context.exception.errno)
def test_activate_permission_denied(self, mock_mkdir): """ Test that activate MPDev works if mkdir returns permission denied """ mock_mkdir.side_effect = [OSError(errno.EPERM, "Permission denied")] with self.assertRaises(OSError) as context: mpath_dmp.activate_MPdev("sid", "dst") self.assertEqual(errno.EPERM, context.exception.errno)
def test_activate_exists_success(self, mock_mkdir, pread2): """ Test that activate MPDev works if directory exists """ mock_mkdir.side_effect = [OSError(errno.EEXIST, "Directory exists")] mpath_dmp.activate_MPdev("sid", "dst") pread2.assert_called_with( ['ln', '-sf', "dst", os.path.join(mpath_dmp.MP_INUSEDIR, "sid")])
def test_activate_no_exception(self, mock_mkdir, pread2): """ Test that activeate MPDev works if directory does not exist """ mpath_dmp.activate_MPdev("sid", "dst") pread2.assert_called_with(['ln', '-sf', "dst", os.path.join(mpath_dmp.MP_INUSEDIR, "sid")])