@@ -37,6 +37,14 @@ def check_background_task_working(tasks: BackgroundTasks):
37
37
return "testing background tasks"
38
38
39
39
40
+ @router .get ("/background-task-with-string-annotation" )
41
+ def check_background_task_working_with_string_annotation (tasks : "BackgroundTasks" ):
42
+ tasks .add_task (background_task_2 )
43
+ tasks .add_task (background_task_1 )
44
+
45
+ return "testing background tasks"
46
+
47
+
40
48
def test_background_tasks_works ():
41
49
global background_task_results
42
50
background_task_results = {}
@@ -65,3 +73,19 @@ def test_any_existing_background_task():
65
73
"background_task_2" : "Called" ,
66
74
"background_task_3" : "Called" ,
67
75
}
76
+
77
+
78
+ def test_any_existing_background_task_with_string_annotation ():
79
+ global background_task_results
80
+ background_task_results = {}
81
+
82
+ client = Test .create_test_module (modules = [ModuleSample ]).get_test_client ()
83
+ res = client .get ("/background-task-with-string-annotation" )
84
+ assert res .status_code == 200
85
+ assert res .text == '"testing background tasks"'
86
+
87
+ assert background_task_results == {
88
+ "background_task_1" : "Called" ,
89
+ "background_task_2" : "Called" ,
90
+ "background_task_3" : "Called" ,
91
+ }
0 commit comments