Skip to content

Commit e077a23

Browse files
committed
Added e2e tests
1 parent 3762527 commit e077a23

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

azure_functions_worker/dispatcher.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ def get_function_metadata(self, directory, caller_info):
327327
default_value=f'{PYTHON_SCRIPT_FILE_NAME_DEFAULT}')
328328

329329
logger.info(
330-
'Received WorkerMetadataRequest from %s, request ID %s, script_file_name: %s',
330+
'Received WorkerMetadataRequest from %s, request ID %s, '
331+
'script_file_name: %s',
331332
caller_info, self.request_id, script_file_name)
332333

333334
try:
@@ -389,7 +390,7 @@ async def _handle__function_load_request(self, request):
389390
# function and update the workers registry
390391

391392
self.get_function_metadata(directory,
392-
caller_info=sys._getframe().f_code.co_name)
393+
sys._getframe().f_code.co_name)
393394
else:
394395
# legacy function
395396
programming_model = "V1"

tests/endtoend/test_http_functions.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def get_script_dir(cls):
205205
'common_libs_functions_stein'
206206

207207

208-
class TestHttpFunctionsWithInitIndexing(testutils.WebHostTestCase):
208+
class TestHttpFunctionsWithInitIndexing(TestHttpFunctions):
209209

210210
@classmethod
211211
def setUpClass(cls):
@@ -218,22 +218,19 @@ def tearDownClass(cls):
218218
os.environ.pop('INIT_INDEXING')
219219
super().tearDownClass()
220220

221+
222+
class TestHttpFunctionsV2WithInitIndexing(TestHttpFunctionsStein):
223+
221224
@classmethod
222-
def get_script_dir(cls):
223-
return testutils.E2E_TESTS_FOLDER / 'http_functions'
225+
def setUpClass(cls):
226+
os.environ["INIT_INDEXING"] = "1"
227+
super().setUpClass()
224228

225-
def test_default_http_template_should_accept_body(self):
226-
"""Test if the azure.functions SDK is able to deserialize http body
227-
and pass it to default template
228-
"""
229-
r = self.webhost.request('POST', 'default_template',
230-
data='{ "name": "body" }'.encode('utf-8'),
231-
timeout=REQUEST_TIMEOUT_SEC)
232-
self.assertTrue(r.ok)
233-
self.assertEqual(
234-
r.content,
235-
b'Hello, body. This HTTP triggered function executed successfully.'
236-
)
229+
@classmethod
230+
def tearDownClass(cls):
231+
# Remove the PYTHON_SCRIPT_FILE_NAME environment variable
232+
os.environ.pop('INIT_INDEXING')
233+
super().tearDownClass()
237234

238235

239236
class TestUserThreadLoggingHttpFunctions(testutils.WebHostTestCase):

tests/endtoend/test_warmup_functions.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22
# Licensed under the MIT License.
33

44
import typing
5+
from unittest import skipIf
56

7+
from azure_functions_worker.utils.common import is_envvar_true
68
from tests.utils import testutils
9+
from tests.utils.constants import DEDICATED_DOCKER_TEST, CONSUMPTION_DOCKER_TEST
710

811

12+
@skipIf(is_envvar_true(DEDICATED_DOCKER_TEST)
13+
or is_envvar_true(CONSUMPTION_DOCKER_TEST),
14+
"Docker tests cannot call admin functions")
915
class TestWarmupFunctions(testutils.WebHostTestCase):
1016
"""Test the Warmup Trigger in the local webhost.
1117
@@ -29,6 +35,9 @@ def check_log_warmup(self, host_out: typing.List[str]):
2935
self.assertEqual(host_out.count("Function App instance is warm"), 1)
3036

3137

38+
@skipIf(is_envvar_true(DEDICATED_DOCKER_TEST)
39+
or is_envvar_true(CONSUMPTION_DOCKER_TEST),
40+
"Docker tests cannot call admin functions")
3241
class TestWarmupFunctionsStein(TestWarmupFunctions):
3342

3443
@classmethod

0 commit comments

Comments
 (0)