diff options
Diffstat (limited to 'res/res/resources/tests.py')
-rw-r--r-- | res/res/resources/tests.py | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/res/res/resources/tests.py b/res/res/resources/tests.py index 689ceff..8ce9550 100644 --- a/res/res/resources/tests.py +++ b/res/res/resources/tests.py @@ -124,7 +124,6 @@ class ResourceTest(TestCase): "relatedtype": 0 }] } - self.volumes_data = { "resp_data": [{ "storageid": "st0", @@ -144,67 +143,77 @@ 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,\ + StorageInstModel(storageid='s02', vimid='vim01', resouceid='resource01', insttype=1, instid=vnf_inst_id, storageDesc='desc01').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) - # self.failUnlessEqual(status.HTTP_200_OK, response.status_code) def test_get_vnfs(self): - for i in range(1): + for i in range(1, 5): 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, storageDesc='desc%s' % i).save() response = self.client.get("/openoapi/vnfres/v1/vnfs") - # self.assertEqual(self.test_data, response.data) 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').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) - # self.failUnlessEqual(status.HTTP_200_OK, response.status_code) 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='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) + self.failUnlessEqual(status.HTTP_200_OK, response.status_code) self.assertEqual(self.flavors_data, response.data) - # self.failUnlessEqual(status.HTTP_200_OK, response.status_code) 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) - # self.failUnlessEqual(status.HTTP_200_OK, response.status_code) 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) - # self.failUnlessEqual(status.HTTP_200_OK, response.status_code) 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) - # self.failUnlessEqual(status.HTTP_200_OK, response.status_code) 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, + disktype='disk%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/resources/swagger.json", format='json') - self.assertEqual(resp.status_code, status.HTTP_200_OK)
\ No newline at end of file + resp = self.client.get("/openoapi/vnfres/v1/swagger.json", format='json') + self.assertEqual(resp.status_code, status.HTTP_200_OK) |