Skip to content

Commit 73f801c

Browse files
committed
Removed uri and add doc strings
1 parent 4f7c6e0 commit 73f801c

File tree

2 files changed

+10
-35
lines changed

2 files changed

+10
-35
lines changed

firebase_admin/functions.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,6 @@ def _validate_task_options(
272272
', or underscores (_). The maximum length is 500 characters.')
273273
task.name = self._get_url(
274274
resource, _CLOUD_TASKS_API_RESOURCE_PATH + f'/{opts.task_id}')
275-
if opts.uri is not None:
276-
if not _Validators.is_url(opts.uri):
277-
raise ValueError(
278-
'uri must be a valid RFC3986 URI string using the https or http schema.')
279-
task.http_request['url'] = opts.uri
280275
return task
281276

282277
def _update_task_payload(self, task: Task, resource: Resource, extension_id: str) -> Task:
@@ -387,17 +382,12 @@ class TaskOptions:
387382
By default, Content-Type is set to 'application/json'.
388383
389384
The size of the headers must be less than 80KB.
390-
391-
uri: The full URL path that the request will be sent to. Must be a valid RFC3986 https or
392-
http URL.
393-
394385
"""
395386
schedule_delay_seconds: Optional[int] = None
396387
schedule_time: Optional[datetime] = None
397388
dispatch_deadline_seconds: Optional[int] = None
398389
task_id: Optional[str] = None
399390
headers: Optional[Dict[str, str]] = None
400-
uri: Optional[str] = None
401391

402392
@dataclass
403393
class Task:
@@ -407,25 +397,25 @@ class Task:
407397
https://cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks#resource:-task
408398
409399
Args:
410-
httpRequest:
411-
name:
412-
schedule_time:
413-
dispatch_deadline:
400+
httpRequest: The request to be made by the task worker.
401+
name: The url path to identify the function.
402+
schedule_time: The time when the task is scheduled to be attempted or retried.
403+
dispatch_deadline: The deadline for requests sent to the worker.
414404
"""
415405
http_request: Dict[str, Optional[str | dict]]
416406
name: Optional[str] = None
417407
schedule_time: Optional[str] = None
418408
dispatch_deadline: Optional[str] = None
419409

420-
410+
Task()
421411
@dataclass
422412
class Resource:
423413
"""Contains the parsed address of a resource.
424414
425415
Args:
426-
resource_id:
427-
project_id:
428-
location_id:
416+
resource_id: The ID of the resource.
417+
project_id: The project ID of the resource.
418+
location_id: The location ID of the resource.
429419
"""
430420
resource_id: str
431421
project_id: Optional[str] = None

tests/test_functions.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,14 @@ def _instrument_functions_service(self, app=None, status=200, payload=_DEFAULT_R
206206
'schedule_time': None,
207207
'dispatch_deadline_seconds': 200,
208208
'task_id': 'test-task-id',
209-
'headers': {'x-test-header': 'test-header-value'},
210-
'uri': 'https://google.com'
209+
'headers': {'x-test-header': 'test-header-value'}
211210
},
212211
{
213212
'schedule_delay_seconds': None,
214213
'schedule_time': _SCHEDULE_TIME,
215214
'dispatch_deadline_seconds': 200,
216215
'task_id': 'test-task-id',
217-
'headers': {'x-test-header': 'test-header-value'},
218-
'uri': 'http://google.com'
216+
'headers': {'x-test-header': 'test-header-value'}
219217
},
220218
])
221219
def test_task_options(self, task_opts_params):
@@ -306,16 +304,3 @@ def test_invalid_task_id_error(self, task_id):
306304
'hyphens (-), or underscores (_). The maximum length is 500 characters.'
307305
)
308306

309-
@pytest.mark.parametrize('uri', [
310-
'', ' ', 'a', 'foo', 'image.jpg', [], {}, True, 'google.com', 'www.google.com',
311-
'file://www.google.com'
312-
])
313-
def test_invalid_uri_error(self, uri):
314-
_, recorder = self._instrument_functions_service()
315-
opts = functions.TaskOptions(uri=uri)
316-
queue = functions.task_queue('test-function-name')
317-
with pytest.raises(ValueError) as excinfo:
318-
queue.enqueue(_DEFAULT_DATA, opts)
319-
assert len(recorder) == 0
320-
assert str(excinfo.value) == \
321-
'uri must be a valid RFC3986 URI string using the https or http schema.'

0 commit comments

Comments
 (0)