def testMissingCpus(self):
     with self.assertRaises(errors.Config.MissingOption) as cm:
         gce_virtual_machine.CustomMachineTypeSpec(_COMPONENT,
                                                   memory='7.5GiB')
     self.assertEqual(
         str(cm.exception),
         ('Required options were missing from test_component: cpus.'))
 def testInvalidCpus(self):
     with self.assertRaises(errors.Config.InvalidValue) as cm:
         gce_virtual_machine.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 testInvalidMemory(self):
     with self.assertRaises(errors.Config.InvalidValue) as cm:
         gce_virtual_machine.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 testExtraOptions(self):
     with self.assertRaises(errors.Config.UnrecognizedOption) as cm:
         gce_virtual_machine.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.'
     ))
Example #5
0
 def testValid(self):
   result = gce_virtual_machine.CustomMachineTypeSpec(_COMPONENT, cpus=1,
                                                      memory='7.5GiB')
   self.assertEqual(result.cpus, 1)
   self.assertEqual(result.memory, 7680)