Esempio n. 1
0
 def test_008_isUserModeLinux(self):
     """Test isUserModeLinux."""
     with patch.object(VMDetect, 'isUserModeLinux',
                       return_value=True) as mock_method:
         vmd = VMDetect()
         vmd.isUserModeLinux()
     mock_method.assert_called()
Esempio n. 2
0
 def test_009_isFreeBSDJAIL(self):
     """Test isFreeBSDJAIL."""
     with patch.object(VMDetect, 'isFreeBSDJAIL',
                       return_value=True) as mock_method:
         vmd = VMDetect()
         vmd.isFreeBSDJAIL()
     mock_method.assert_called()
Esempio n. 3
0
 def test_005_isVMware(self):
     """Test isVMware."""
     with patch.object(VMDetect, 'isVMware',
                       return_value=True) as mock_method:
         vmd = VMDetect()
         vmd.isVMware()
     mock_method.assert_called()
Esempio n. 4
0
 def test_007_isHyperV(self):
     """Test isHyperV."""
     with patch.object(VMDetect, 'isHyperV',
                       return_value=True) as mock_method:
         vmd = VMDetect()
         vmd.isHyperV()
     mock_method.assert_called()
Esempio n. 5
0
 def test_004_isXENDomU(self):
     """Test isXENDomU."""
     with patch.object(VMDetect, 'isXENDomU',
                       return_value=True) as mock_method:
         vmd = VMDetect()
         vmd.isXENDomU()
     mock_method.assert_called()
Esempio n. 6
0
 def test_003_isOpenVZ(self):
     """Test isOpenVZ."""
     with patch.object(VMDetect, 'isOpenVZ',
                       return_value=True) as mock_method:
         vmd = VMDetect()
         vmd.isOpenVZ()
     mock_method.assert_called()
Esempio n. 7
0
 def test_002_is_vm_provider_by_cpuid_retruns(self):
     """Test vm_provider_by_cpuid ."""
     with patch.object(VMDetect, 'vm_provider_by_cpuid',
                       return_value=True) as mock_method:
         vmd = VMDetect()
         vmd.vm_provider_by_cpuid()
     mock_method.assert_called()
Esempio n. 8
0
def main(test_type=None):
    """Console script for py_vmdetect."""
    vmd = VMDetect()

    if not test_type:
        click.echo("Is Virtual: {}".format("yes" if vmd.is_vm() else "no"))
        return 0

    if re.match('is_vm', test_type):
        click.echo("Is Virtual: {}".format("yes" if vmd.is_vm() else "no"))
    elif re.match('vm_provider_by_cpuid', test_type):
        click.echo("VM Provider by CPUID: {}".format(
            vmd.vm_provider_by_cpuid()))
    elif re.match('isVMware', test_type):
        click.echo("Is VMware: {}".format("yes" if vmd.isVMware() else "no"))
    elif re.match('isHyperV', test_type):
        click.echo("Is HyperV: {}".format("yes" if vmd.isHyperV() else "no"))
    elif re.match('isOpenVZ', test_type):
        click.echo("Is OpenVZ: {}".format("yes" if vmd.isOpenVZ() else "no"))
    elif re.match('isUserModeLinux', test_type):
        click.echo("Is UserModeLinux: {}".format(
            "yes" if vmd.isUserModeLinux() else "no"))
    elif re.match('isKvm', test_type):
        click.echo("Is Kvm: {}".format("yes" if vmd.isKvm() else "no"))
    elif re.match('isXENDomU', test_type):
        click.echo("Is XEN: {}".format("yes" if vmd.isXENDomU() else "no"))
    elif re.match('isFreeBSDJAIL', test_type):
        click.echo("Is FreeBSD JAIL: {}".format(
            "yes" if vmd.isFreeBSDJAIL() else "no"))
    return 0
Esempio n. 9
0
 def test_006_isKvm(self):
     """Test isKvm."""
     with patch.object(VMDetect, 'isKvm', return_value=True) as mock_method:
         vmd = VMDetect()
         vmd.isKvm()
     mock_method.assert_called()
Esempio n. 10
0
 def test_001_is_vm_returns_true(self):
     """Test is_vm returns true."""
     with patch.object(VMDetect, 'is_vm', return_value=True) as mock_method:
         vmd = VMDetect()
         vmd.is_vm()
     mock_method.assert_called_once()