def test_pvcreate(self):
        self.assertEqual(linux_lvm.pvcreate(''),
                         'Error: at least one device is required')

        self.assertRaises(CommandExecutionError, linux_lvm.pvcreate, 'A')

        pvdisplay = MagicMock(return_value=True)
        with patch('salt.modules.linux_lvm.pvdisplay', pvdisplay):
            with patch.object(os.path, 'exists', return_value=True):
                ret = {'stdout': 'saltines', 'stderr': 'cheese', 'retcode': 0, 'pid': '1337'}
                mock = MagicMock(return_value=ret)
                with patch.dict(linux_lvm.__salt__, {'cmd.run_all': mock}):
                    self.assertEqual(linux_lvm.pvcreate('A', metadatasize=1000), True)
Tests for set a physical device to be used as an LVM physical volume
dataset/ETHPy150Open saltstack/salt/tests/unit/modules/linux_lvm_test.py/LinuxLVMTestCase.test_pvcreate