def test_featuresElement(self): """Testing OvfLibvirt.featuresElement""" self.assertEqual(Ovf.xmlString(OvfLibvirt.featuresElement(True, True, True, True)), '<features><pae/><nonpae/><acpi/><apic/></features>') self.assertEqual(Ovf.xmlString(OvfLibvirt.featuresElement(pae=True)), '<features><pae/></features>') self.assertEqual(Ovf.xmlString(OvfLibvirt.featuresElement(nonpae=True)), '<features><nonpae/></features>') self.assertEqual(Ovf.xmlString(OvfLibvirt.featuresElement(acpi=True)), '<features><acpi/></features>') self.assertEqual(Ovf.xmlString(OvfLibvirt.featuresElement(apic=True)), '<features><apic/></features>')
def test_libvirtDocument(self): """Testing OvfLibvirt.libvirtDocument""" domain = self.testDocument.createElement('domain') domain.setAttribute('type', 'xen') elem = self.testDocument.createElement('name') elem.appendChild(self.testDocument.createTextNode('test')) domain.appendChild(elem) # no sections testDoc = OvfLibvirt.libvirtDocument(domain) testStr = self.docTag + '<domain type="xen"><name>test</name></domain>' self.assertEqual(Ovf.xmlString(testDoc), testStr) # new section clockSection = self.testDocument.createElement('clock') clockSection.setAttribute('sync','utc') testDoc = OvfLibvirt.libvirtDocument(domain, clockSection) testStr = self.docTag + '<domain type="xen"><name>test</name>' + \ '<clock sync="utc"/></domain>' self.assertEqual(Ovf.xmlString(testDoc), testStr) # replace section domain.appendChild(clockSection) newClockSection = self.testDocument.createElement('clock') newClockSection.setAttribute('sync','localtime') testDoc = OvfLibvirt.libvirtDocument(domain, newClockSection) testStr = self.docTag + '<domain type="xen"><name>test</name>' + \ '<clock sync="localtime"/></domain>' self.assertEqual(Ovf.xmlString(testDoc), testStr) # multiple sections (new and old) newNameSection = self.testDocument.createElement('name') nameNode = self.testDocument.createTextNode('test_completed') newNameSection.appendChild(nameNode) testDoc = OvfLibvirt.libvirtDocument(domain, newNameSection, newClockSection) testStr = self.docTag + '<domain type="xen">' + \ '<name>test_completed</name>' + \ '<clock sync="localtime"/></domain>' self.assertEqual(Ovf.xmlString(testDoc), testStr)
def test_uuidElement(self): """Testing OvfLibvirt.uuidElement""" testStr = '4dea22b31d52d8f32516782e98ab3fa0' self.assertEqual(Ovf.xmlString(OvfLibvirt.uuidElement(testStr)), '<uuid>' + testStr + '</uuid>')
def test_nameElement(self): """Testing OvfLibvirt.nameElement""" self.assertEqual(Ovf.xmlString(OvfLibvirt.nameElement('test')), '<name>test</name>')
def test_domainElement(self): """Testing OvfLibvirt.domainElement""" testElem = OvfLibvirt.domainElement('kqemu') self.assertEqual(Ovf.xmlString(testElem), '<domain type="kqemu"/>')
def test_graphicsElement(self): """Testing OvfLibvirt.graphicsElement""" self.assertEqual(Ovf.xmlString(OvfLibvirt.graphicsElement('vnc', '192.168.1.1', '6522')), '<graphics listen="192.168.1.1" port="6522" type="vnc"/>') self.assertEqual(Ovf.xmlString(OvfLibvirt.graphicsElement('sdl')), '<graphics type="sdl"/>')
def test_inputElement(self): """Testing OvfLibvirt.inputElement""" self.assertEqual(Ovf.xmlString(OvfLibvirt.inputElement('mouse', 'usb')), '<input bus="usb" type="mouse"/>') self.assertEqual(Ovf.xmlString(OvfLibvirt.inputElement('tablet')), '<input type="tablet"/>')
def test_emulatorElement(self): """Testing OvfLibvirt.emulatorElement""" testElem = OvfLibvirt.emulatorElement('/usr/bin/qemu') self.assertEqual(Ovf.xmlString(testElem), '<emulator>/usr/bin/qemu</emulator>')
def test_clockElement(self): """Testing OvfLibvirt.clockElement""" self.assertEqual(Ovf.xmlString(OvfLibvirt.clockElement('localtime')), '<clock sync="localtime"/>')
def test_onCrashElement(self): """Testing OvfLibvirt.onCrashElement""" self.assertEqual(Ovf.xmlString(OvfLibvirt.onCrashElement('restart')), '<on_crash>restart</on_crash>')
def test_onRebootElement(self): """Testing OvfLibvirt.onRebootElement""" self.assertEqual(Ovf.xmlString(OvfLibvirt.onRebootElement('restart')), '<on_reboot>restart</on_reboot>')
def test_onPowerOffElement(self): """Testing OvfLibvirt.onPowerOffElement""" self.assertEqual(Ovf.xmlString(OvfLibvirt.onPowerOffElement('destroy')), '<on_poweroff>destroy</on_poweroff>')
def test_vcpuElement(self): """Testing OvfLibvirt.vcpuElement""" self.assertEqual(Ovf.xmlString(OvfLibvirt.vcpuElement('1')), '<vcpu>1</vcpu>')
def test_currentMemoryElement(self): """Testing OvfLibvirt.currentMemoryElement""" self.assertEqual(Ovf.xmlString(OvfLibvirt.currentMemoryElement('262144')), '<currentMemory>262144</currentMemory>')
def test_memoryElement(self): """Testing OvfLibvirt.memoryElement""" self.assertEqual(Ovf.xmlString(OvfLibvirt.memoryElement('262144')), '<memory>262144</memory>')