1
1
# Copyright (c) Microsoft Corporation. All rights reserved.
2
2
# Licensed under the MIT License.
3
+ import json
4
+ import os
5
+ import time
3
6
from unittest import skipIf
7
+ from unittest .mock import patch
8
+
9
+ import requests
4
10
5
11
from azure_functions_worker .utils .common import is_envvar_true
6
12
from tests .utils import testutils
9
15
10
16
@skipIf (is_envvar_true (DEDICATED_DOCKER_TEST )
11
17
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" )
14
19
class TestDurableFunctions (testutils .WebHostTestCase ):
15
20
16
21
@classmethod
17
22
def setUpClass (cls ):
18
- # webhook for durable tests
19
23
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 ()
20
29
super ().setUpClass ()
21
30
31
+ @classmethod
32
+ def tearDownClass (cls ):
33
+ super ().tearDownClass ()
34
+ cls ._patch_environ .stop ()
35
+
22
36
@classmethod
23
37
def get_libraries_to_install (cls ):
24
38
return ['azure-functions-durable' ]
@@ -34,4 +48,22 @@ def get_script_dir(cls):
34
48
def test_durable (self ):
35
49
r = self .webhost .request ('GET' ,
36
50
'orchestrators/DurableFunctionsOrchestrator' )
51
+ time .sleep (4 ) # wait for the activity to complete
37
52
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