|
17 | 17 | from firebase_functions import options, https_fn
|
18 | 18 | from firebase_functions import params
|
19 | 19 | from firebase_functions.private.serving import functions_as_yaml, merge_required_apis
|
| 20 | +from pytest import raises |
20 | 21 | # pylint: disable=protected-access
|
21 | 22 |
|
22 | 23 |
|
@@ -44,7 +45,7 @@ def test_global_options_merged_with_provider_options():
|
44 | 45 | Testing a global option is used when no provider option is set.
|
45 | 46 | """
|
46 | 47 | options.set_global_options(max_instances=66)
|
47 |
| - pubsub_options = options.PubSubOptions(topic="foo") #pylint: disable=unexpected-keyword-arg |
| 48 | + pubsub_options = options.PubSubOptions(topic="foo") # pylint: disable=unexpected-keyword-arg |
48 | 49 | pubsub_options_dict = pubsub_options._asdict_with_global_options()
|
49 | 50 | assert (pubsub_options_dict["topic"] == "foo"
|
50 | 51 | ), "'topic' property missing from dict"
|
@@ -170,7 +171,7 @@ def test_merge_apis_duplicate_apis():
|
170 | 171 | This test evaluates the merge_required_apis function when the
|
171 | 172 | input list contains duplicate APIs with different reasons.
|
172 | 173 | The desired outcome for this test is a list where the duplicate
|
173 |
| - APIs are merged properly and reasons are combined. |
| 174 | + APIs are merged properly and reasons are combined. |
174 | 175 | This test ensures that the function correctly merges the duplicate
|
175 | 176 | APIs and combines the reasons associated with them.
|
176 | 177 | """
|
@@ -217,3 +218,16 @@ def test_merge_apis_duplicate_apis():
|
217 | 218 | for actual_item in merged_apis:
|
218 | 219 | assert (actual_item in expected_output
|
219 | 220 | ), f"Unexpected item {actual_item} found in the merged list"
|
| 221 | + |
| 222 | + |
| 223 | +def test_invoker_with_one_element_doesnt_throw(): |
| 224 | + options.HttpsOptions(invoker=["public"])._endpoint(func_name="test") |
| 225 | + |
| 226 | + |
| 227 | +def test_invoker_with_no_element_throws(): |
| 228 | + with raises( |
| 229 | + AssertionError, |
| 230 | + match= |
| 231 | + "HttpsOptions: Invalid option for invoker - must be a non-empty list." |
| 232 | + ): |
| 233 | + options.HttpsOptions(invoker=[])._endpoint(func_name="test") |
1 commit comments
sjudd commentedon Sep 19, 2024
I'd love to see this released! :)