File tree Expand file tree Collapse file tree 5 files changed +70
-0
lines changed
blueprint_functions/blueprint_different_dir Expand file tree Collapse file tree 5 files changed +70
-0
lines changed Original file line number Diff line number Diff line change
1
+ import logging
2
+ import time
3
+ from datetime import datetime
4
+
5
+ import azure .functions as func
6
+
7
+ bp = func .Blueprint ()
8
+
9
+
10
+ @bp .route (route = "default_template" )
11
+ def default_template (req : func .HttpRequest ) -> func .HttpResponse :
12
+ logging .info ('Python HTTP trigger function processed a request.' )
13
+
14
+ name = req .params .get ('name' )
15
+ if not name :
16
+ try :
17
+ req_body = req .get_json ()
18
+ except ValueError :
19
+ pass
20
+ else :
21
+ name = req_body .get ('name' )
22
+
23
+ if name :
24
+ return func .HttpResponse (
25
+ f"Hello, { name } . This HTTP triggered function "
26
+ f"executed successfully." )
27
+ else :
28
+ return func .HttpResponse (
29
+ "This HTTP triggered function executed successfully. "
30
+ "Pass a name in the query string or in the request body for a"
31
+ " personalized response." ,
32
+ status_code = 200
33
+ )
34
+
35
+
36
+ @bp .route (route = "http_func" )
37
+ def http_func (req : func .HttpRequest ) -> func .HttpResponse :
38
+ time .sleep (1 )
39
+
40
+ current_time = datetime .now ().strftime ("%H:%M:%S" )
41
+ return func .HttpResponse (f"{ current_time } " )
Original file line number Diff line number Diff line change
1
+ import azure .functions as func
2
+ from blueprint_directory .blueprint import bp
3
+
4
+ app = func .FunctionApp (http_auth_level = func .AuthLevel .ANONYMOUS )
5
+
6
+ app .register_functions (bp )
Original file line number Diff line number Diff line change @@ -53,3 +53,17 @@ def test_only_blueprint(self):
53
53
"""
54
54
r = self .webhost .request ('GET' , 'default_template' )
55
55
self .assertEqual (r .status_code , 404 )
56
+
57
+
58
+ class TestBlueprintDifferentDirectory (testutils .WebHostTestCase ):
59
+ @classmethod
60
+ def get_script_dir (cls ):
61
+ return testutils .E2E_TESTS_FOLDER / 'blueprint_functions' / \
62
+ 'blueprint_different_dir'
63
+
64
+ def test_blueprint_in_different_dir (self ):
65
+ r = self .webhost .request ('GET' , 'default_template' )
66
+ self .assertTrue (r .ok )
67
+
68
+ r = self .webhost .request ('GET' , 'http_func' )
69
+ self .assertTrue (r .ok )
Original file line number Diff line number Diff line change @@ -71,3 +71,11 @@ class TestWorkerProcessCountWithBlueprintStein(TestWorkerProcessCount):
71
71
def get_script_dir (cls ):
72
72
return testutils .E2E_TESTS_FOLDER / 'blueprint_functions' / \
73
73
'functions_in_blueprint_only'
74
+
75
+
76
+ class TestWorkerProcessCountWithBlueprintDiffDirStein (TestWorkerProcessCount ):
77
+
78
+ @classmethod
79
+ def get_script_dir (cls ):
80
+ return testutils .E2E_TESTS_FOLDER / 'blueprint_functions' / \
81
+ 'blueprint_different_dir'
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ def tearDownClass(cls):
38
38
def get_script_dir (cls ):
39
39
return testutils .UNIT_TESTS_FOLDER / 'log_filtering_functions'
40
40
41
+ @testutils .retryable_test (4 , 5 )
41
42
def test_debug_logging_enabled (self ):
42
43
"""
43
44
Verify when cx debug logging is enabled, cx function debug logs
You can’t perform that action at this time.
0 commit comments