20
20
)
21
21
from azure .functions .decorators .http import HttpTrigger , HttpOutput , \
22
22
HttpMethod
23
- from azure .functions .decorators .timer import TimerTrigger
24
23
from azure .functions .decorators .retry_policy import RetryPolicy
25
24
from test_core import DummyTrigger
26
25
from tests .utils .testutils import assert_json
@@ -291,10 +290,6 @@ def test_unique_method_names2(name: str):
291
290
"test_unique_method_names" )
292
291
self .assertEqual (functions [1 ].get_function_name (),
293
292
"test_unique_method_names2" )
294
- self .assertIsInstance (app ._function_builders [0 ].function_bindings .get (
295
- "test_unique_method_names" )[0 ], TimerTrigger )
296
- self .assertIsInstance (app ._function_builders [0 ].function_bindings .get (
297
- "test_unique_method_names2" )[0 ], TimerTrigger )
298
293
299
294
def test_unique_function_names (self ):
300
295
app = FunctionApp ()
@@ -316,10 +311,6 @@ def test_unique_function_names2(name: str):
316
311
"test_unique_function_names" )
317
312
self .assertEqual (functions [1 ].get_function_name (),
318
313
"test_unique_function_names2" )
319
- self .assertIsInstance (app ._function_builders [0 ].function_bindings .get (
320
- "test_unique_function_names" )[0 ], TimerTrigger )
321
- self .assertIsInstance (app ._function_builders [0 ].function_bindings .get (
322
- "test_unique_function_names2" )[0 ], TimerTrigger )
323
314
324
315
def test_same_method_names (self ):
325
316
app = FunctionApp ()
@@ -425,10 +416,6 @@ def test_blueprint_unique_method_names2(name: str):
425
416
"test_blueprint_unique_method_names" )
426
417
self .assertEqual (functions [1 ].get_function_name (),
427
418
"test_blueprint_unique_method_names2" )
428
- self .assertIsInstance (app ._function_builders [0 ].function_bindings .get (
429
- "test_blueprint_unique_method_names" )[0 ], TimerTrigger )
430
- self .assertIsInstance (app ._function_builders [0 ].function_bindings .get (
431
- "test_blueprint_unique_method_names2" )[0 ], TimerTrigger )
432
419
433
420
def test_blueprint_unique_function_names (self ):
434
421
app = FunctionApp ()
@@ -454,10 +441,6 @@ def test_blueprint_unique_function_names2(name: str):
454
441
"test_blueprint_unique_function_names" )
455
442
self .assertEqual (functions [1 ].get_function_name (),
456
443
"test_blueprint_unique_function_names2" )
457
- self .assertIsInstance (app ._function_builders [0 ].function_bindings .get (
458
- "test_blueprint_unique_function_names" )[0 ], TimerTrigger )
459
- self .assertIsInstance (app ._function_builders [0 ].function_bindings .get (
460
- "test_blueprint_unique_function_names2" )[0 ], TimerTrigger )
461
444
462
445
def test_blueprint_same_method_names (self ):
463
446
app = FunctionApp ()
@@ -1009,3 +992,43 @@ def _test_http_external_app(self, app, is_async, function_name):
1009
992
"type" : HTTP_OUTPUT
1010
993
}
1011
994
]})
995
+
996
+
997
+ class TestFunctionRegister (unittest .TestCase ):
998
+ def test_validate_empty_dict (self ):
999
+ def dummy ():
1000
+ return "dummy"
1001
+
1002
+ test_func = Function (dummy , "dummy.py" )
1003
+ fr = FunctionRegister (auth_level = "ANONYMOUS" )
1004
+ fr .validate_function_names (functions = [test_func ])
1005
+
1006
+ def test_validate_unique_names (self ):
1007
+ def dummy ():
1008
+ return "dummy"
1009
+
1010
+ def dummy2 ():
1011
+ return "dummy"
1012
+
1013
+ test_func = Function (dummy , "dummy.py" )
1014
+ test_func2 = Function (dummy2 , "dummy.py" )
1015
+
1016
+ fr = FunctionRegister (auth_level = "ANONYMOUS" )
1017
+ fr .validate_function_names (
1018
+ functions = [test_func , test_func2 ])
1019
+
1020
+ def test_validate_non_unique_names (self ):
1021
+ def dummy ():
1022
+ return "dummy"
1023
+
1024
+ test_func = Function (dummy , "dummy.py" )
1025
+ test_func2 = Function (dummy , "dummy.py" )
1026
+
1027
+ fr = FunctionRegister (auth_level = "ANONYMOUS" )
1028
+ with self .assertRaises (ValueError ) as err :
1029
+ fr .validate_function_names (functions = [test_func , test_func2 ])
1030
+ self .assertEqual (err .exception .args [0 ],
1031
+ "Function dummy does not have"
1032
+ " a unique function name."
1033
+ " Please change @app.function_name()"
1034
+ " or the function method name to be unique." )
0 commit comments