| 1 |
from lxml import objectify |
| 2 |
|
| 3 |
from kiwi.storage.subformat.template.virtualbox_ovf import ( |
| 4 |
VirtualboxOvfTemplate |
| 5 |
) |
| 6 |
|
| 7 |
|
| 8 |
class TestVirtualboxOvfTemplate: |
| 9 |
def setup(self): |
| 10 |
self.ovf_template = VirtualboxOvfTemplate() |
| 11 |
|
| 12 |
def setup_method(self, cls): |
| 13 |
self.setup() |
| 14 |
|
| 15 |
def test_ovf_parameters(self): |
| 16 |
args = { |
| 17 |
'vm_name': 'jumper', |
| 18 |
'root_uuid': 'uuid', |
| 19 |
'vm_description': 'Leap 15 image', |
| 20 |
'disk_image_capacity': 21, |
| 21 |
} |
| 22 |
ovf_file = self.ovf_template.get_template().substitute(args) |
| 23 |
ovf = objectify.fromstring(ovf_file) |
| 24 |
|
| 25 |
for (attr, value) in ovf.DiskSection.Disk.items(): |
| 26 |
if 'capacity' in attr: |
| 27 |
assert value == str(args['disk_image_capacity']) |
| 28 |
|
| 29 |
vm_name_attr, vm_name_value = ovf.VirtualSystem.items()[0] |
| 30 |
assert 'id' in vm_name_attr and vm_name_value == args['vm_name'] |
| 31 |
|
| 32 |
cimos_id_attr, cimos_id_value = \ |
| 33 |
ovf.VirtualSystem.OperatingSystemSection.items()[0] |
| 34 |
assert 'id' in cimos_id_attr and int(cimos_id_value) == 101 |
| 35 |
|
| 36 |
assert ovf.VirtualSystem.OperatingSystemSection.Description \ |
| 37 |
== args['vm_description'] |