e3befcaa7bf95e1b26d3da6e0886985b539455bd
[modeling/etsicatalog.git] / genericparser / packages / tests / test_health_check.py
1 # Copyright (c) 2019, CMCC Technologies Co., Ltd.
2
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
6
7 # http://www.apache.org/licenses/LICENSE-2.0
8
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.
14
15 import json
16
17 from django.test import TestCase, Client
18 from rest_framework import status
19
20
21 class TestHealthCheck(TestCase):
22     def setUp(self):
23         self.client = Client()
24
25     def tearDown(self):
26         pass
27
28     def test_vnfpkgm_health_check(self):
29         response = self.client.get("/api/vnfpkgm/v1/health_check")
30         self.assertEqual(status.HTTP_200_OK, response.status_code, response.content)
31         resp_data = json.loads(response.content)
32         self.assertEqual({"status": "active"}, resp_data)
33
34     def test_nsd_health_check(self):
35         response = self.client.get("/api/nsd/v1/health_check")
36         self.assertEqual(status.HTTP_200_OK, response.status_code, response.content)
37         resp_data = json.loads(response.content)
38         self.assertEqual({"status": "active"}, resp_data)
39
40     def test_catalog_health_check(self):
41         response = self.client.get("/api/genericparser/v1/health_check")
42         self.assertEqual(status.HTTP_200_OK, response.status_code, response.content)
43         resp_data = json.loads(response.content)
44         self.assertEqual({"status": "active"}, resp_data)
45
46     def test_parser_health_check(self):
47         response = self.client.get("/api/parser/v1/health_check")
48         self.assertEqual(status.HTTP_200_OK, response.status_code, response.content)
49         resp_data = json.loads(response.content)
50         self.assertEqual({"status": "active"}, resp_data)