|
17 | 17 | import json
|
18 | 18 | import numbers
|
19 | 19 |
|
20 |
| -from googleapiclient.http import HttpMockSequence |
| 20 | +from googleapiclient import http |
| 21 | +from googleapiclient import _helpers |
21 | 22 | import pytest
|
22 | 23 |
|
23 | 24 | import firebase_admin
|
@@ -1810,7 +1811,7 @@ def _instrument_batch_messaging_service(self, app=None, status=200, payload=''):
|
1810 | 1811 | content_type = 'multipart/mixed; boundary=boundary'
|
1811 | 1812 | else:
|
1812 | 1813 | content_type = 'application/json'
|
1813 |
| - fcm_service._transport = HttpMockSequence([ |
| 1814 | + fcm_service._transport = http.HttpMockSequence([ |
1814 | 1815 | ({'status': str(status), 'content-type': content_type}, payload),
|
1815 | 1816 | ])
|
1816 | 1817 | return fcm_service
|
@@ -1867,6 +1868,20 @@ def test_send_all(self):
|
1867 | 1868 | assert all([r.success for r in batch_response.responses])
|
1868 | 1869 | assert not any([r.exception for r in batch_response.responses])
|
1869 | 1870 |
|
| 1871 | + def test_send_all_with_positional_param_enforcement(self): |
| 1872 | + payload = json.dumps({'name': 'message-id'}) |
| 1873 | + _ = self._instrument_batch_messaging_service( |
| 1874 | + payload=self._batch_payload([(200, payload), (200, payload)])) |
| 1875 | + msg = messaging.Message(topic='foo') |
| 1876 | + |
| 1877 | + enforcement = _helpers.positional_parameters_enforcement |
| 1878 | + _helpers.positional_parameters_enforcement = _helpers.POSITIONAL_EXCEPTION |
| 1879 | + try: |
| 1880 | + batch_response = messaging.send_all([msg, msg], dry_run=True) |
| 1881 | + assert batch_response.success_count == 2 |
| 1882 | + finally: |
| 1883 | + _helpers.positional_parameters_enforcement = enforcement |
| 1884 | + |
1870 | 1885 | @pytest.mark.parametrize('status', HTTP_ERROR_CODES)
|
1871 | 1886 | def test_send_all_detailed_error(self, status):
|
1872 | 1887 | success_payload = json.dumps({'name': 'message-id'})
|
|
0 commit comments