update link to upper-constraints.txt
[vfc/nfvo/lcm.git] / lcm / ns / tests / test_ns_get.py
1 # Copyright 2017 ZTE Corporation.\r
2 #\r
3 # Licensed under the Apache License, Version 2.0 (the "License");\r
4 # you may not use this file except in compliance with the License.\r
5 # You may obtain a copy of the License at\r
6 #\r
7 #         http://www.apache.org/licenses/LICENSE-2.0\r
8 #\r
9 # Unless required by applicable law or agreed to in writing, software\r
10 # distributed under the License is distributed on an "AS IS" BASIS,\r
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
12 # See the License for the specific language governing permissions and\r
13 # limitations under the License.\r
14 from django.test import TestCase, Client\r
15 from rest_framework import status\r
16 \r
17 from lcm.pub.database.models import NSInstModel\r
18 \r
19 \r
20 class TestNsQuery(TestCase):\r
21     def setUp(self):\r
22         self.client = Client()\r
23         NSInstModel(id=1, nsd_id=11, name='test01').save()\r
24         NSInstModel(id=2, nsd_id=22, name='test02').save()\r
25 \r
26     def tearDown(self):\r
27         NSInstModel.objects.all().delete()\r
28 \r
29     def test_query_ns_by_nsinstance_id(self):\r
30         response = self.client.get("/api/nslcm/v1/ns/1")\r
31         self.assertEqual(status.HTTP_200_OK, response.status_code)\r
32         self.assertIsNotNone(response.data)\r
33 \r
34     def test_query_all_nsinstance(self):\r
35         response = self.client.get("/api/nslcm/v1/ns")\r
36         self.assertEqual(status.HTTP_200_OK, response.status_code, response.data)\r
37         self.assertIsNotNone(response.data)\r
38         self.assertEqual(2, len(response.data))\r
39 \r
40     def test_query_ns_by_non_existing_nsinstance_id(self):\r
41         response = self.client.get("/api/nslcm/v1/ns/200")\r
42         self.assertEqual(status.HTTP_404_NOT_FOUND, response.status_code)\r