11# Copyright (c) Microsoft Corporation. All rights reserved.
22# Licensed under the MIT License.
3+ import json
4+ import os
5+ import time
36from unittest import skipIf
7+ from unittest .mock import patch
8+
9+ import requests
410
511from azure_functions_worker .utils .common import is_envvar_true
612from tests .utils import testutils
915
1016@skipIf (is_envvar_true (DEDICATED_DOCKER_TEST )
1117 or is_envvar_true (CONSUMPTION_DOCKER_TEST ),
12- "TODO: This will be fixed in "
13- "https://github.com/Azure/azure-functions-python-worker/pull/1199" )
18+ "Docker tests cannot retrieve port needed for a webhook" )
1419class TestDurableFunctions (testutils .WebHostTestCase ):
1520
1621 @classmethod
1722 def setUpClass (cls ):
18- # webhook for durable tests
1923 cls .env_variables ['WEBSITE_HOSTNAME' ] = "http:"
24+ os_environ = os .environ .copy ()
25+ os_environ .update (cls .env_variables )
26+
27+ cls ._patch_environ = patch .dict ('os.environ' , os_environ )
28+ cls ._patch_environ .start ()
2029 super ().setUpClass ()
2130
31+ @classmethod
32+ def tearDownClass (cls ):
33+ super ().tearDownClass ()
34+ cls ._patch_environ .stop ()
35+
2236 @classmethod
2337 def get_libraries_to_install (cls ):
2438 return ['azure-functions-durable' ]
@@ -34,4 +48,22 @@ def get_script_dir(cls):
3448 def test_durable (self ):
3549 r = self .webhost .request ('GET' ,
3650 'orchestrators/DurableFunctionsOrchestrator' )
51+ time .sleep (4 ) # wait for the activity to complete
3752 self .assertEqual (r .status_code , 202 )
53+ content = json .loads (r .content )
54+
55+ status = requests .get (content ['statusQueryGetUri' ])
56+ self .assertEqual (status .status_code , 200 )
57+
58+ status_content = json .loads (status .content )
59+ self .assertEqual (status_content ['runtimeStatus' ], 'Completed' )
60+ self .assertEqual (status_content ['output' ],
61+ ['Hello Tokyo!' , 'Hello Seattle!' , 'Hello London!' ])
62+
63+
64+ class TestDurableFunctionsStein (TestDurableFunctions ):
65+
66+ @classmethod
67+ def get_script_dir (cls ):
68+ return testutils .E2E_TESTS_FOLDER / 'durable_functions' / \
69+ 'durable_functions_stein'
0 commit comments