def test_support_spice(self): """Checks that VirtController.supports_spice() returns True if the version of Libvirt is >= 8.0.6 """ MockLibvirt.version = 8005 self.assertIs(VirtController.supports_spice(), False) MockLibvirt.version = 8006 self.assertIs(VirtController.supports_spice(), True)
def __parse_graphics(self, conf): """ Parses the graphics parameter over the conf dictionary given in parameter and raises appropriate exception if a problem is found. """ if conf.has_key('graphics'): graphics = conf['graphics'] if type(graphics) is not str: raise CloubedConfigurationException( "format of graphics parameter of domain {domain} " \ "is not valid" \ .format(domain=self.name)) valid_graphics = ["sdl", "vnc", "rdp", "spice"] if graphics not in valid_graphics: raise CloubedConfigurationException( "value {graphics} of graphics parameter of domain " \ "{domain} is not valid" \ .format(graphics=graphics, domain=self.name)) self.graphics = graphics else: # default is spice if controller has support if VirtController.supports_spice(): self.graphics = "spice" else: self.graphics = "vnc"
def test_parse_graphics_ok(self): """ ConfigurationDomain.__parse_graphics() should properly set graphics attribute """ conf = { 'graphics': 'vnc' } self.domain_conf._ConfigurationDomain__parse_graphics(conf) self.assertEqual(self.domain_conf.graphics, 'vnc') conf = { } # default is spice if controller supports else it is vnc self.domain_conf._ConfigurationDomain__parse_graphics(conf) if VirtController.supports_spice(): self.assertEqual(self.domain_conf.graphics, 'spice') else: self.assertEqual(self.domain_conf.graphics, 'vnc')