summaryrefslogtreecommitdiffstats
path: root/res/res/resources/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'res/res/resources/tests.py')
-rw-r--r--res/res/resources/tests.py70
1 files changed, 33 insertions, 37 deletions
diff --git a/res/res/resources/tests.py b/res/res/resources/tests.py
index 8ce9550..2ab5a0a 100644
--- a/res/res/resources/tests.py
+++ b/res/res/resources/tests.py
@@ -43,7 +43,7 @@ class ResourceTest(TestCase):
"extVirtualLink": [],
"monitoringParameters": {},
"localizationLanguage": None,
- "vimInfo": [],
+ "vmInfo": [],
"vnfcResourceInfo": [],
"virtualLinkResourceInfo": [],
"virtualStorageResourceInfo": [
@@ -70,23 +70,28 @@ class ResourceTest(TestCase):
"instid": u"01",
"vmname": u"v1",
"operationalstate": None,
- "zoneid": None,
"tenant": None,
- "hostid": None,
- "detailinfo": None,
- "is_predefined": 0
+ "is_predefined": 0,
+ "security_groups": 'sec0',
+ "flavor_id": 'flavor0',
+ "availability_zone": 'ava0',
+ "server_group": 'server0',
+ "volume_array": 'volume0',
+ "metadata": 'meta0',
+ "nic_array": 'nic0'
}]
}
self.flavors_data = {
"resp_data": [{
"flavourid": "fla0",
"name": "fname0",
- "vcpu": "cpu0",
- "memory": "mem0",
+ "vcpu": 0,
+ "memory": 0,
"extraspecs": "ext0",
"instid": "01",
"tenant": None,
- "vmid": "vm0",
+ "vimid": "vim0",
+ "resouceid": 'res0',
"create_time": None
}]
}
@@ -124,6 +129,7 @@ class ResourceTest(TestCase):
"relatedtype": 0
}]
}
+
self.volumes_data = {
"resp_data": [{
"storageid": "st0",
@@ -132,8 +138,7 @@ class ResourceTest(TestCase):
"insttype": 0,
"instid": "01",
"storagetype": "stype0",
- "size": "0",
- "disktype": "disk0"
+ "size": "0"
}]
}
@@ -143,77 +148,68 @@ class ResourceTest(TestCase):
def test_get_vnf(self):
vnf_inst_id = "1"
NfInstModel(nfinstid=vnf_inst_id, nf_name='VNF1').save()
- StorageInstModel(storageid='s02', vimid='vim01', resouceid='resource01', insttype=1,
- instid=vnf_inst_id, storageDesc='desc01').save()
+ StorageInstModel(storageid='s02', vimid='vim01', resouceid='resource01', insttype=1,\
+ instid=vnf_inst_id, storagetype='desc01', size='ten').save()
response = self.client.get("/openoapi/vnfres/v1/vnfs/%s" % vnf_inst_id)
self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(self.test_data, response.data)
+
def test_get_vnfs(self):
- for i in range(1, 5):
+ for i in range(1):
NfInstModel(nfinstid='%s' % i, nf_name='VNF%s' % i).save()
- StorageInstModel(storageid='s0%s' % i, vimid='vim0%s' % i, resouceid='resource0%s' % i,
- insttype=1, instid='%s' % i, storageDesc='desc%s' % i).save()
+ StorageInstModel(storageid='s0%s' % i, vimid='vim0%s' % i, resouceid='resource0%s' % i, insttype=1, instid='%s' % i, storagetype='desc%s' % i, size='ten').save()
response = self.client.get("/openoapi/vnfres/v1/vnfs")
self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
# self.assertEqual(self.test_data, response.data)
def test_get_vms(self):
NfInstModel(nfinstid='%s' % '01', nf_name='VFS%s' % '01').save()
- nfinst = NfInstModel.objects.get(pk='01')
+ nfInst = NfInstModel.objects.get(pk='01')
for i in range(1):
- VmInstModel(vmid='vm%s' % i, vimid='vim%s' % i, resouceid='res%s' % i,
- instid='%s' % nfinst.nfinstid, insttype=0, vmname='v1').save()
- response = self.client.get("/openoapi/vnfres/v1/%s/vms" % nfinst.nfinstid)
+ VmInstModel(vmid='vm%s' % i, vimid='vim%s' % i, resouceid='res%s' % i, instid='%s' % nfInst.nfinstid, insttype=0, vmname='v1', nic_array='nic%s' % i, metadata='meta%s' % i, volume_array='volume%s' % i, server_group='server%s' % i, availability_zone='ava%s' %i, flavor_id='flavor%s' % i, security_groups='sec%s' % i).save()
+ response = self.client.get("/openoapi/vnfres/v1/%s/vms" % nfInst.nfinstid)
self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(self.vms_data, response.data)
def test_get_flavors(self):
NfInstModel(nfinstid='%s' % '01', nf_name='VFS%s' % '01').save()
- nfinst = NfInstModel.objects.get(pk='01')
+ nfInst = NfInstModel.objects.get(pk='01')
for i in range(1):
- FlavourInstModel(flavourid='fla%s' % i, name='fname%s' % i, vcpu='cpu%s' % i,
- instid='%s' % nfinst.nfinstid, memory='mem%s' % i,
- extraspecs='ext%s' % i, vmid='vm%s' % i).save()
- response = self.client.get("/openoapi/vnfres/v1/%s/flavors" % nfinst.nfinstid)
+ FlavourInstModel(flavourid='fla%s' % i, name='fname%s' % i, vcpu='%d' % i, instid='%s' % nfInst.nfinstid, memory='%d' % i, extraspecs='ext%s' % i, vimid='vim%s' % i, resouceid='res%s' % i).save()
+ response = self.client.get("/openoapi/vnfres/v1/%s/flavors" % nfInst.nfinstid)
self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(self.flavors_data, response.data)
def test_get_networks(self):
for i in range(1):
- NetworkInstModel(networkid='net%s' % i, name='net_name%s' % i, vimid='vim%s' % i,
- instid='%s' % self.nf_inst_id, resouceid='res%s' % i, insttype='%d' % i).save()
+ NetworkInstModel(networkid='net%s' % i, name='net_name%s' % i, vimid='vim%s' % i, instid='%s' % self.nf_inst_id,
+ resouceid='res%s' % i, insttype='%d' % i).save()
response = self.client.get("/openoapi/vnfres/v1/%s/networks" % self.nf_inst_id)
self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(self.networks_data, response.data)
def test_get_subnets(self):
for i in range(1):
- SubNetworkInstModel(subnetworkid="sub%s" % i, vimid='vim%s' % i, resouceid='res%s' % i,
- networkid='net%s' % i, insttype='%d' % i, instid='%s' % self.nf_inst_id,
- name='sub_name%s' % i, cidr="cidr%s" % i).save()
+ SubNetworkInstModel(subnetworkid="sub%s" % i, vimid='vim%s' % i, resouceid='res%s' % i, networkid='net%s' % i, insttype='%d' % i, instid='%s' % self.nf_inst_id, name='sub_name%s' % i, cidr="cidr%s" % i).save()
response = self.client.get("/openoapi/vnfres/v1/%s/subnets" % self.nf_inst_id)
self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(self.subnets_data, response.data)
def test_get_cps(self):
for i in range(1):
- CPInstModel(cpinstanceid="cp%s" % i, cpdid='cpd%s' % i, cpinstancename='cpinstname%s' % i,
- vlinstanceid='vlinst%s' % i, ownertype='%d' % i, ownerid='%s' % self.nf_inst_id,
- relatedtype='%d' % i).save()
+ CPInstModel(cpinstanceid="cp%s" % i, cpdid='cpd%s' % i, cpinstancename='cpinstname%s' % i, vlinstanceid='vlinst%s' % i, ownertype='%d' % i, ownerid='%s' % self.nf_inst_id, relatedtype='%d' % i).save()
response = self.client.get("/openoapi/vnfres/v1/%s/cps" % self.nf_inst_id)
self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(self.cps_data, response.data)
def test_get_volumes(self):
for i in range(1):
- StorageInstModel(storageid="st%s" % i, vimid='vim%s' % i, resouceid='res%s' % i, insttype='%d' % i,
- instid='%s' % self.nf_inst_id, storagetype='stype%s' % i, size='%s' % i,
- disktype='disk%s' % i).save()
+ StorageInstModel(storageid="st%s" % i, vimid='vim%s' % i, resouceid='res%s' % i, insttype='%d' % i, instid='%s' % self.nf_inst_id, storagetype='stype%s' % i, size='%s' % i).save()
response = self.client.get("/openoapi/vnfres/v1/%s/volumes" % self.nf_inst_id)
- self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(self.volumes_data, response.data)
+ self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
def test_swagger_ok(self):
resp = self.client.get("/openoapi/vnfres/v1/swagger.json", format='json')
- self.assertEqual(resp.status_code, status.HTTP_200_OK)
+ self.assertEqual(resp.status_code, status.HTTP_200_OK, resp.content) \ No newline at end of file