summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2017-08-17 10:54:27 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2017-08-17 10:54:27 +0800
commitcf4b8a979cc09bf8a17646f6351889245dcd168d (patch)
tree1beafddc0435b5c990803f6045f5d4cc72deabf0
parent377d81d6b21db51a7397418c62d494577f7835f0 (diff)
Add nf pkg distribute test cases
Change-Id: I03c3907080158452c5e2ef4302ad5773a21d5dd1 Issue-Id: VFC-103 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r--lcm/packages/tests/test_sdc_nf.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/lcm/packages/tests/test_sdc_nf.py b/lcm/packages/tests/test_sdc_nf.py
index c7b6818e..c498617d 100644
--- a/lcm/packages/tests/test_sdc_nf.py
+++ b/lcm/packages/tests/test_sdc_nf.py
@@ -11,3 +11,42 @@
# 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 mock
+from rest_framework import status
+from django.test import TestCase
+from django.test import Client
+
+from lcm.pub.utils import restcall
+from lcm.pub.utils import fileutil
+from lcm.pub.database.models import NfPackageModel, NfInstModel
+from lcm.pub.database.models import JobStatusModel, JobModel
+from lcm.packages.sdc_nf_package import SdcNfDistributeThread, SdcNfPkgDeleteThread
+from lcm.packages import sdc_nf_package
+
+
+class TestNfPackage(TestCase):
+ def setUp(self):
+ self.client = Client()
+ NfPackageModel.objects.filter().delete()
+ NfInstModel.objects.filter().delete()
+ JobModel.objects.filter().delete()
+ JobStatusModel.objects.filter().delete()
+
+ def tearDown(self):
+ pass
+
+ def assert_job_result(self, job_id, job_progress, job_detail):
+ jobs = JobStatusModel.objects.filter(
+ jobid=job_id,
+ progress=job_progress,
+ descp=job_detail)
+ self.assertEqual(1, len(jobs))
+
+ @mock.patch.object(SdcNfDistributeThread, 'run')
+ def test_nf_pkg_on_distribute_normal(self, mock_run):
+ resp = self.client.post("/api/nslcm/v1/vnfpackage", {
+ "csarId": "1",
+ "vimIds": ["1"]
+ }, format='json')
+ self.assertEqual(resp.status_code, status.HTTP_202_ACCEPTED)