def testInvalidMemory(self): with self.assertRaises(errors.Config.InvalidValue) as cm: custom_virtual_machine_spec.CustomMachineTypeSpec( _COMPONENT, cpus=1, memory=None) self.assertEqual(str(cm.exception), ( 'Invalid test_component.memory value: "None" (of type "NoneType"). ' 'Value must be one of the following types: basestring.'))
def testMissingMemory(self): with self.assertRaises(errors.Config.MissingOption) as cm: custom_virtual_machine_spec.CustomMachineTypeSpec(_COMPONENT, cpus=1) self.assertEqual( str(cm.exception), ('Required options were missing from test_component: memory.'))
def testInvalidCpus(self): with self.assertRaises(errors.Config.InvalidValue) as cm: custom_virtual_machine_spec.CustomMachineTypeSpec(_COMPONENT, cpus=0, memory='7.5GiB') self.assertEqual(str(cm.exception), ( 'Invalid test_component.cpus value: "0". Value must be at least 1.' ))
def testExtraOptions(self): with self.assertRaises(errors.Config.UnrecognizedOption) as cm: custom_virtual_machine_spec.CustomMachineTypeSpec(_COMPONENT, cpus=1, memory='7.5GiB', extra1='one', extra2=2) self.assertEqual(str(cm.exception), ( 'Unrecognized options were found in test_component: extra1, extra2.' ))
def testValid(self): result = custom_virtual_machine_spec.CustomMachineTypeSpec( _COMPONENT, cpus=1, memory='7.5GiB') self.assertEqual(result.cpus, 1) self.assertEqual(result.memory, 7680)