X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=lcm%2Flcm%2Fnf%2Fvnfs%2Ftests%2Ftest_vnf_cancel.py;h=748a39c51026d57c4e6c7bceb36ef4b65b1146e6;hb=5249d950efa79784f5b14b3492bbd511aa72ea67;hp=2f139e5619bca88da535bab5e0dddf4817b00fe1;hpb=5d7d95aaa0b4e3ccf016c275a686d02e80d744b7;p=vfc%2Fgvnfm%2Fvnflcm.git diff --git a/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py b/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py index 2f139e56..748a39c5 100644 --- a/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py +++ b/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py @@ -11,6 +11,7 @@ # # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # # limitations under the License. +import json import uuid import mock @@ -20,6 +21,7 @@ from rest_framework import status from lcm.nf.vnfs.vnf_cancel.term_vnf import TermVnf from lcm.pub.database.models import NfInstModel, JobStatusModel, VmInstModel, NetworkInstModel, SubNetworkInstModel, \ PortInstModel, NfvoRegInfoModel +from lcm.pub.utils import restcall from lcm.pub.utils.jobutil import JobUtil from lcm.pub.utils.timeutil import now_time @@ -90,12 +92,15 @@ class TestNFTerminate(TestCase): self.assert_job_result(self.job_id, 255, "VnfInst(%s) does not exist" % self.nf_inst_id) - - def test_terminate_vnf_success(self): + @mock.patch.object(restcall, 'call_req') + def test_terminate_vnf_success(self, mock_call_req): NfInstModel.objects.create(nfinstid='1111', nf_name='2222', package_id='todo', version='', vendor='', netype='', vnfd_model='', status='VNF_INSTANTIATED', nf_desc='', vnfdid='', vnfSoftwareVersion='', vnfConfigurableProperties='todo', localizationLanguage='EN_US', create_time=now_time()) + t1_apply_grant_result = [0, json.JSONEncoder().encode( + {"vim": {"vimid": 'vimid_1', "accessinfo": {"tenant": 'tenantname_1'}}}), '200'] + mock_call_req.side_effect = [t1_apply_grant_result] data = {"terminationType": "FORCEFUL", "gracefulTerminationTimeout": 120} self.nf_inst_id = '1111'