-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathtest_swagger.py
96 lines (74 loc) · 3.45 KB
/
test_swagger.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
"""Test common rest operations wrapper.
"""
import os
import unittest
from pyms.constants import CONFIGMAP_FILE_ENVIRONMENT
from tests.common import MyMicroserviceNoSingleton
class SwaggerTests(unittest.TestCase):
"""Test common rest operations wrapper."""
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
def setUp(self):
os.environ[CONFIGMAP_FILE_ENVIRONMENT] = os.path.join(self.BASE_DIR, "config-tests-swagger.yml")
ms = MyMicroserviceNoSingleton(path=__file__)
ms.reload_conf()
self.app = ms.create_app()
self.client = self.app.connexion_app.test_client()
self.assertEqual("Python Microservice Swagger", self.app.config["APP_NAME"])
def test_default(self):
response = self.client.get("/test-api-path/ws-doc/")
self.assertEqual(200, response.status_code)
def test_home(self):
response = self.client.get("/test-api-path/")
self.assertEqual(200, response.status_code)
# class SwaggerNoAbsPathTests(unittest.TestCase):
# """Test common rest operations wrapper."""
#
# BASE_DIR = os.path.dirname(os.path.abspath(__file__))
#
# def setUp(self):
# os.environ[CONFIGMAP_FILE_ENVIRONMENT] = os.path.join(self.BASE_DIR, "config-tests-swagger_no_abs_path.yml")
# ms = MyMicroserviceNoSingleton(path=__file__)
# ms.reload_conf()
# self.app = ms.create_app()
# self.client = self.app.connexion_app.test_client()
# self.assertEqual("Python Microservice Swagger2", self.app.config["APP_NAME"])
#
# def test_default(self):
# response = self.client.get("/test-api-path2/ws-doc2/")
# self.assertEqual(200, response.status_code)
#
# def test_home(self):
# response = self.client.get("/test-api-path2/no-abs-path")
# self.assertEqual(200, response.status_code)
class SwaggerOpenapi3Tests(unittest.TestCase):
"""Test common rest operations wrapper."""
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
def setUp(self):
os.environ[CONFIGMAP_FILE_ENVIRONMENT] = os.path.join(self.BASE_DIR, "config-tests-swagger_3.yml")
ms = MyMicroserviceNoSingleton(path=__file__)
ms.reload_conf()
self.app = ms.create_app()
self.client = self.app.connexion_app.test_client()
self.assertEqual("Python Microservice Swagger Openapi 3", self.app.config["APP_NAME"])
def test_default(self):
response = self.client.get("/ws-doc/")
self.assertEqual(200, response.status_code)
def test_home(self):
response = self.client.get("/test-url")
self.assertEqual(200, response.status_code)
class SwaggerOpenapi3NoAbsPathTests(unittest.TestCase):
"""Test common rest operations wrapper."""
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
def setUp(self):
os.environ[CONFIGMAP_FILE_ENVIRONMENT] = os.path.join(self.BASE_DIR, "config-tests-swagger_3_no_abs_path.yml")
ms = MyMicroserviceNoSingleton(path=__file__)
ms.reload_conf()
self.app = ms.create_app()
self.client = self.app.connexion_app.test_client()
self.assertEqual("Python Microservice Swagger Openapi 3 No abspath", self.app.config["APP_NAME"])
def test_default(self):
response = self.client.get("/test-api-path2/ws-doc2/")
self.assertEqual(200, response.status_code)
def test_home(self):
response = self.client.get("/test-api-path2/test-url")
self.assertEqual(200, response.status_code)