2
2
# Licensed under the MIT License.
3
3
4
4
import unittest
5
+
5
6
from azure .functions import Function
7
+ from azure .functions .decorators .blob import BlobInput
6
8
from azure .functions .decorators .http import HttpTrigger
7
9
8
10
from azure_functions_worker import functions
@@ -19,13 +21,29 @@ def dummy():
19
21
self .func = Function (self .dummy , "test.py" )
20
22
self .function_registry = functions .Registry ()
21
23
22
- def test_add_index_functions_invalid_route (self ):
23
- function_id = '123'
24
+ def test_add_indexed_function_invalid_route (self ):
25
+ trigger1 = HttpTrigger (name = "req1" , route = "/" )
26
+ self .func .add_trigger (trigger = trigger1 )
27
+
28
+ with self .assertRaises (FunctionLoadError ) as ex :
29
+ self .function_registry .add_indexed_function (function_id = '123' ,
30
+ function = self .func )
24
31
25
- trigger1 = HttpTrigger (name = "req1" ,
26
- route = "/" )
32
+ self .assertEqual (str (ex .exception ),
33
+ 'cannot load the dummy function: Invalid route name: '
34
+ '/. Route name cannot begin with a /' )
35
+
36
+ def test_add_indexed_function_invalid_direction (self ):
37
+ trigger1 = HttpTrigger (name = "req1" , route = "test" )
38
+ binding = BlobInput (name = "$return" , path = "testpath" ,
39
+ connection = "testconnection" )
27
40
self .func .add_trigger (trigger = trigger1 )
41
+ self .func .add_binding (binding = binding )
42
+
43
+ with self .assertRaises (FunctionLoadError ) as ex :
44
+ self .function_registry .add_indexed_function (function_id = '123' ,
45
+ function = self .func )
28
46
29
- with self .assertRaises ( FunctionLoadError ):
30
- self . function_registry . add_indexed_function ( function_id ,
31
- self . func )
47
+ self .assertEqual ( str ( ex . exception ),
48
+ 'cannot load the dummy function: \" $return \" '
49
+ 'binding must have direction set to \" out \" ' )
0 commit comments