1
1
# Copyright (c) Microsoft Corporation. All rights reserved.
2
2
# Licensed under the MIT License.
3
- from unittest import TestCase , skipIf
4
-
5
3
import os
6
4
import sys
7
- from requests import Request
5
+ from unittest import TestCase , skipIf
8
6
9
7
from azure_functions_worker .testutils_lc import (
10
8
LinuxConsumptionWebHostController
11
9
)
12
10
from azure_functions_worker .utils .common import is_python_version
11
+ from requests import Request
12
+
13
+ _DEFAULT_HOST_VERSION = "3"
13
14
14
15
15
16
@skipIf (is_python_version ('3.10' ),
@@ -42,7 +43,8 @@ def test_placeholder_mode_root_returns_ok(self):
42
43
"""In any circumstances, a placeholder container should returns 200
43
44
even when it is not specialized.
44
45
"""
45
- with LinuxConsumptionWebHostController ("3" , self ._py_version ) as ctrl :
46
+ with LinuxConsumptionWebHostController (_DEFAULT_HOST_VERSION ,
47
+ self ._py_version ) as ctrl :
46
48
req = Request ('GET' , ctrl .url )
47
49
resp = ctrl .send_request (req )
48
50
self .assertTrue (resp .ok )
@@ -51,7 +53,8 @@ def test_http_no_auth(self):
51
53
"""An HttpTrigger function app with 'azure-functions' library
52
54
should return 200.
53
55
"""
54
- with LinuxConsumptionWebHostController ("3" , self ._py_version ) as ctrl :
56
+ with LinuxConsumptionWebHostController (_DEFAULT_HOST_VERSION ,
57
+ self ._py_version ) as ctrl :
55
58
ctrl .assign_container (env = {
56
59
"AzureWebJobsStorage" : self ._storage ,
57
60
"SCM_RUN_FROM_PACKAGE" : self ._get_blob_url ("HttpNoAuth" )
@@ -60,6 +63,8 @@ def test_http_no_auth(self):
60
63
resp = ctrl .send_request (req )
61
64
self .assertEqual (resp .status_code , 200 )
62
65
66
+ @skipIf (is_python_version ('3.7' ),
67
+ "Skip the tests for Python 3.7." )
63
68
def test_common_libraries (self ):
64
69
"""A function app with the following requirements.txt:
65
70
@@ -73,7 +78,8 @@ def test_common_libraries(self):
73
78
74
79
should return 200 after importing all libraries.
75
80
"""
76
- with LinuxConsumptionWebHostController ("3" , self ._py_version ) as ctrl :
81
+ with LinuxConsumptionWebHostController (_DEFAULT_HOST_VERSION ,
82
+ self ._py_version ) as ctrl :
77
83
ctrl .assign_container (env = {
78
84
"AzureWebJobsStorage" : self ._storage ,
79
85
"SCM_RUN_FROM_PACKAGE" : self ._get_blob_url ("CommonLibraries" )
@@ -98,7 +104,8 @@ def test_new_protobuf(self):
98
104
99
105
should return 200 after importing all libraries.
100
106
"""
101
- with LinuxConsumptionWebHostController ("3" , self ._py_version ) as ctrl :
107
+ with LinuxConsumptionWebHostController (_DEFAULT_HOST_VERSION ,
108
+ self ._py_version ) as ctrl :
102
109
ctrl .assign_container (env = {
103
110
"AzureWebJobsStorage" : self ._storage ,
104
111
"SCM_RUN_FROM_PACKAGE" : self ._get_blob_url ("NewProtobuf" )
@@ -123,10 +130,11 @@ def test_old_protobuf(self):
123
130
124
131
should return 200 after importing all libraries.
125
132
"""
126
- with LinuxConsumptionWebHostController ("3" , self ._py_version ) as ctrl :
133
+ with LinuxConsumptionWebHostController (_DEFAULT_HOST_VERSION ,
134
+ self ._py_version ) as ctrl :
127
135
ctrl .assign_container (env = {
128
136
"AzureWebJobsStorage" : self ._storage ,
129
- "SCM_RUN_FROM_PACKAGE" : self ._get_blob_url ("NewProtobuf " )
137
+ "SCM_RUN_FROM_PACKAGE" : self ._get_blob_url ("OldProtobuf " )
130
138
})
131
139
req = Request ('GET' , f'{ ctrl .url } /api/HttpTrigger' )
132
140
resp = ctrl .send_request (req )
@@ -144,7 +152,8 @@ def test_debug_logging_disabled(self):
144
152
should return 200 and by default customer debug logging should be
145
153
disabled.
146
154
"""
147
- with LinuxConsumptionWebHostController ("3" , self ._py_version ) as ctrl :
155
+ with LinuxConsumptionWebHostController (_DEFAULT_HOST_VERSION ,
156
+ self ._py_version ) as ctrl :
148
157
ctrl .assign_container (env = {
149
158
"AzureWebJobsStorage" : self ._storage ,
150
159
"SCM_RUN_FROM_PACKAGE" : self ._get_blob_url ("EnableDebugLogging" )
@@ -170,7 +179,8 @@ def test_debug_logging_enabled(self):
170
179
should return 200 and with customer debug logging enabled, debug logs
171
180
should be written to container logs.
172
181
"""
173
- with LinuxConsumptionWebHostController ("3" , self ._py_version ) as ctrl :
182
+ with LinuxConsumptionWebHostController (_DEFAULT_HOST_VERSION ,
183
+ self ._py_version ) as ctrl :
174
184
ctrl .assign_container (env = {
175
185
"AzureWebJobsStorage" : self ._storage ,
176
186
"SCM_RUN_FROM_PACKAGE" : self ._get_blob_url (
0 commit comments