11# Copyright (c) Microsoft Corporation. All rights reserved.
22# Licensed under the MIT License.
3- from unittest import TestCase , skipIf
4-
53import os
64import sys
7- from requests import Request
5+ from unittest import TestCase , skipIf
86
97from azure_functions_worker .testutils_lc import (
108 LinuxConsumptionWebHostController
119)
1210from azure_functions_worker .utils .common import is_python_version
11+ from requests import Request
12+
13+ _DEFAULT_HOST_VERSION = "3"
1314
1415
1516@skipIf (is_python_version ('3.10' ),
@@ -42,7 +43,8 @@ def test_placeholder_mode_root_returns_ok(self):
4243 """In any circumstances, a placeholder container should returns 200
4344 even when it is not specialized.
4445 """
45- with LinuxConsumptionWebHostController ("3" , self ._py_version ) as ctrl :
46+ with LinuxConsumptionWebHostController (_DEFAULT_HOST_VERSION ,
47+ self ._py_version ) as ctrl :
4648 req = Request ('GET' , ctrl .url )
4749 resp = ctrl .send_request (req )
4850 self .assertTrue (resp .ok )
@@ -51,7 +53,8 @@ def test_http_no_auth(self):
5153 """An HttpTrigger function app with 'azure-functions' library
5254 should return 200.
5355 """
54- with LinuxConsumptionWebHostController ("3" , self ._py_version ) as ctrl :
56+ with LinuxConsumptionWebHostController (_DEFAULT_HOST_VERSION ,
57+ self ._py_version ) as ctrl :
5558 ctrl .assign_container (env = {
5659 "AzureWebJobsStorage" : self ._storage ,
5760 "SCM_RUN_FROM_PACKAGE" : self ._get_blob_url ("HttpNoAuth" )
@@ -60,6 +63,8 @@ def test_http_no_auth(self):
6063 resp = ctrl .send_request (req )
6164 self .assertEqual (resp .status_code , 200 )
6265
66+ @skipIf (is_python_version ('3.7' ),
67+ "Skip the tests for Python 3.7." )
6368 def test_common_libraries (self ):
6469 """A function app with the following requirements.txt:
6570
@@ -73,7 +78,8 @@ def test_common_libraries(self):
7378
7479 should return 200 after importing all libraries.
7580 """
76- with LinuxConsumptionWebHostController ("3" , self ._py_version ) as ctrl :
81+ with LinuxConsumptionWebHostController (_DEFAULT_HOST_VERSION ,
82+ self ._py_version ) as ctrl :
7783 ctrl .assign_container (env = {
7884 "AzureWebJobsStorage" : self ._storage ,
7985 "SCM_RUN_FROM_PACKAGE" : self ._get_blob_url ("CommonLibraries" )
@@ -98,7 +104,8 @@ def test_new_protobuf(self):
98104
99105 should return 200 after importing all libraries.
100106 """
101- with LinuxConsumptionWebHostController ("3" , self ._py_version ) as ctrl :
107+ with LinuxConsumptionWebHostController (_DEFAULT_HOST_VERSION ,
108+ self ._py_version ) as ctrl :
102109 ctrl .assign_container (env = {
103110 "AzureWebJobsStorage" : self ._storage ,
104111 "SCM_RUN_FROM_PACKAGE" : self ._get_blob_url ("NewProtobuf" )
@@ -123,10 +130,11 @@ def test_old_protobuf(self):
123130
124131 should return 200 after importing all libraries.
125132 """
126- with LinuxConsumptionWebHostController ("3" , self ._py_version ) as ctrl :
133+ with LinuxConsumptionWebHostController (_DEFAULT_HOST_VERSION ,
134+ self ._py_version ) as ctrl :
127135 ctrl .assign_container (env = {
128136 "AzureWebJobsStorage" : self ._storage ,
129- "SCM_RUN_FROM_PACKAGE" : self ._get_blob_url ("NewProtobuf " )
137+ "SCM_RUN_FROM_PACKAGE" : self ._get_blob_url ("OldProtobuf " )
130138 })
131139 req = Request ('GET' , f'{ ctrl .url } /api/HttpTrigger' )
132140 resp = ctrl .send_request (req )
@@ -144,7 +152,8 @@ def test_debug_logging_disabled(self):
144152 should return 200 and by default customer debug logging should be
145153 disabled.
146154 """
147- with LinuxConsumptionWebHostController ("3" , self ._py_version ) as ctrl :
155+ with LinuxConsumptionWebHostController (_DEFAULT_HOST_VERSION ,
156+ self ._py_version ) as ctrl :
148157 ctrl .assign_container (env = {
149158 "AzureWebJobsStorage" : self ._storage ,
150159 "SCM_RUN_FROM_PACKAGE" : self ._get_blob_url ("EnableDebugLogging" )
@@ -170,7 +179,8 @@ def test_debug_logging_enabled(self):
170179 should return 200 and with customer debug logging enabled, debug logs
171180 should be written to container logs.
172181 """
173- with LinuxConsumptionWebHostController ("3" , self ._py_version ) as ctrl :
182+ with LinuxConsumptionWebHostController (_DEFAULT_HOST_VERSION ,
183+ self ._py_version ) as ctrl :
174184 ctrl .assign_container (env = {
175185 "AzureWebJobsStorage" : self ._storage ,
176186 "SCM_RUN_FROM_PACKAGE" : self ._get_blob_url (
0 commit comments