def test_vm_without_dmi_bios_info(self): """ Test for the case, when MS BIOS does not provide any useful information for our code """ # We will mock facts using simple dictionary facts = {} azure_detector = azure.AzureCloudDetector(facts) is_vm = azure_detector.is_vm() self.assertFalse(is_vm) is_azure_vm = azure_detector.is_running_on_cloud() self.assertFalse(is_azure_vm)
def test_azure_not_vm(self): """ Test for the case, when the machine is host (not virtual machine) """ # We will mock facts using simple dictionary facts = { 'virt.is_guest': False, 'dmi.bios.version': 'cool hardware company' } azure_detector = azure.AzureCloudDetector(facts) is_vm = azure_detector.is_vm() self.assertFalse(is_vm)
def test_vm_not_on_azure_cloud(self): """ Test for the case, when the vm is not running on AWS """ # We will mock facts using simple dictionary facts = { 'virt.is_guest': True, 'virt.host_type': 'hyperv', 'dmi.bios.version': '090008', 'dmi.bios.vendor': 'Foo' } azure_detector = azure.AzureCloudDetector(facts) is_vm = azure_detector.is_vm() self.assertTrue(is_vm) is_azure_vm = azure_detector.is_running_on_cloud() self.assertFalse(is_azure_vm)
def test_azure_vm(self): """ Test for the case, when the vm is running on Azure """ # We will mock facts using simple dictionary facts = { 'virt.is_guest': True, 'virt.host_type': 'hyperv', 'dmi.bios.version': '090008', 'dmi.chassis.asset_tag': '7783-7084-3265-9085-8269-3286-77' } azure_detector = azure.AzureCloudDetector(facts) is_vm = azure_detector.is_vm() self.assertTrue(is_vm) is_azure_vm = azure_detector.is_running_on_cloud() self.assertTrue(is_azure_vm)