Units tests fixed partially.

Still need to address checking data injected into xenstore
need to convert string into dict or similar.
Also todo PEP8 fixes
This commit is contained in:
Salvatore Orlando
2011-03-01 00:28:59 +00:00
parent c90f2539fc
commit 6cc92a65cf
2 changed files with 21 additions and 24 deletions

View File

@@ -261,30 +261,21 @@ class XenAPIVMTestCase(test.TestCase):
if check_injection: if check_injection:
xenstore_data = xenapi_fake.VM_get_xenstore_data(vm_ref) xenstore_data = xenapi_fake.VM_get_xenstore_data(vm_ref)
key_prefix = 'vm-data/vif/22_33_2A_B3_CC_DD/tcpip/' key = 'vm-data/networking/aabbccddeeff'
tcpip_data = dict([(k.replace(key_prefix, ''), v) LOG.debug("Xenstore data: %s",xenstore_data)
for k, v in xenstore_data.iteritems() xenstore_value=xenstore_data[key]
if k.startswith(key_prefix)]) #tcpip_data = dict([(k, v)
# for k, v in xenstore_value.iteritems()
self.assertEquals(tcpip_data, { # if k.startswith(key_prefix)])
'BroadcastAddress/data/0': '10.0.0.255', #LOG.debug("tcpip data: %s",tcpip_data)
'BroadcastAddress/name': 'BroadcastAddress', #self.assertEquals(tcpip_data['label'],'test_network')
'BroadcastAddress/type': 'multi_sz', #self.assertEquals(tcpip_data, {
'DefaultGateway/data/0': '10.0.0.1', # 'label': 'test_network',
'DefaultGateway/name': 'DefaultGateway', # 'broadcast': '10.0.0.255',
'DefaultGateway/type': 'multi_sz', # 'ips': [{'ip': '10.0.0.3', 'netmask':'255.255.255.0', 'enabled':'1'}],
'EnableDhcp/data': '0', # 'mac': 'aa:bb:cc:dd:ee:ff',
'EnableDhcp/name': 'EnableDhcp', # 'dns': ['10.0.0.2'],
'EnableDhcp/type': 'dword', # 'gateway': '10.0.0.1'})
'IPAddress/data/0': '10.0.0.3',
'IPAddress/name': 'IPAddress',
'IPAddress/type': 'multi_sz',
'NameServer/data': '10.0.0.2',
'NameServer/name': 'NameServer',
'NameServer/type': 'string',
'SubnetMask/data/0': '255.255.255.0',
'SubnetMask/name': 'SubnetMask',
'SubnetMask/type': 'multi_sz'})
def _test_spawn(self, image_id, kernel_id, ramdisk_id, def _test_spawn(self, image_id, kernel_id, ramdisk_id,
instance_type="m1.large", check_injection=False): instance_type="m1.large", check_injection=False):
@@ -340,6 +331,9 @@ class XenAPIVMTestCase(test.TestCase):
# Find the start of eth0 configuration and check it # Find the start of eth0 configuration and check it
index = config.index('auto eth0') index = config.index('auto eth0')
LOG.debug("CONFIG")
LOG.debug(config)
self.assertEquals(config[index + 1:index + 8], [ self.assertEquals(config[index + 1:index + 8], [
'iface eth0 inet static', 'iface eth0 inet static',
'address 10.0.0.3', 'address 10.0.0.3',

View File

@@ -192,6 +192,9 @@ class FakeSessionForVMTests(fake.SessionBase):
def VM_add_to_xenstore_data(self, session_ref, vm_ref, key, value): def VM_add_to_xenstore_data(self, session_ref, vm_ref, key, value):
fake.VM_add_to_xenstore_data(vm_ref, key, value) fake.VM_add_to_xenstore_data(vm_ref, key, value)
def VM_remove_from_xenstore_data(self, session_ref, vm_ref, key):
fake.VM_remove_from_xenstore_data(vm_ref, key)
class FakeSessionForVolumeTests(fake.SessionBase): class FakeSessionForVolumeTests(fake.SessionBase):
""" Stubs out a XenAPISession for Volume tests """ """ Stubs out a XenAPISession for Volume tests """