1 # Copyright 2017 ZTE Corporation.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 from rest_framework import status
17 from django.test import TestCase
18 from django.test import Client
20 from lcm.pub.utils import restcall
21 from lcm.pub.utils import fileutil
22 from lcm.pub.database.models import NfPackageModel, NfInstModel
23 from lcm.pub.database.models import JobStatusModel, JobModel
24 from lcm.packages.sdc_nf_package import SdcNfDistributeThread, SdcNfPkgDeleteThread
25 from lcm.packages import sdc_nf_package
28 class TestNfPackage(TestCase):
30 self.client = Client()
31 NfPackageModel.objects.filter().delete()
32 NfInstModel.objects.filter().delete()
33 JobModel.objects.filter().delete()
34 JobStatusModel.objects.filter().delete()
39 def assert_job_result(self, job_id, job_progress, job_detail):
40 jobs = JobStatusModel.objects.filter(
42 progress=job_progress,
44 self.assertEqual(1, len(jobs))
46 @mock.patch.object(SdcNfDistributeThread, 'run')
47 def test_nf_pkg_on_distribute_normal(self, mock_run):
48 resp = self.client.post("/api/nslcm/v1/vnfpackage", {
52 self.assertEqual(resp.status_code, status.HTTP_202_ACCEPTED)