Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Migration Guide Snippets for Cloud Tasks #2316

Merged
merged 7 commits into from
Aug 6, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lint
  • Loading branch information
averikitsch committed Aug 6, 2019
commit faa3997138b1c906d3027176b2077b0ad7c91b5c
5 changes: 3 additions & 2 deletions appengine/flexible/tasks/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from google.cloud import tasks


def create_queue(project, location, queue_blue_name, queue_red_name):
# [START taskqueues_using_yaml]
client = tasks.CloudTasksClient()
Expand Down Expand Up @@ -106,6 +107,7 @@ def create_task(project, location, queue):
# [END taskqueues_new_task]
return response


def create_tasks_with_data(project, location, queue):
# [START taskqueues_passing_data]
import json
Expand Down Expand Up @@ -162,7 +164,7 @@ def create_task_with_name(project, location, queue, task_name):

parent = client.queue_path(project, location, queue)

task = {
task = {
'name': client.task_path(project, location, queue, task_name),
'app_engine_http_request': {
'http_method': 'GET',
Expand Down Expand Up @@ -230,7 +232,6 @@ def retry_task(project, location, fooqueue, barqueue, bazqueue):
# barqueue = 'barqueue'
# bazqueue = 'bazqueue'


parent = client.location_path(project, location)

max_retry = duration_pb2.Duration()
Expand Down
12 changes: 5 additions & 7 deletions appengine/flexible/tasks/snippets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
QUEUE_NAME_1 = "queue-{}".format(uuid.uuid4())
QUEUE_NAME_2 = "queue-{}".format(uuid.uuid4())


@pytest.mark.order1
def test_create_queue():
name = "projects/{}/locations/{}/queues/{}".format(
Expand Down Expand Up @@ -79,17 +80,13 @@ def test_delete_task():

@pytest.mark.order8
def test_delete_queue():
name = "projects/{}/locations/{}/queues/{}".format(
TEST_PROJECT_ID, TEST_LOCATION, QUEUE_NAME_1)
result = snippets.delete_queue(
TEST_PROJECT_ID, TEST_LOCATION, QUEUE_NAME_1)
assert None == result
assert result is None

name = "projects/{}/locations/{}/queues/{}".format(
TEST_PROJECT_ID, TEST_LOCATION, QUEUE_NAME_2)
result = snippets.delete_queue(
TEST_PROJECT_ID, TEST_LOCATION, QUEUE_NAME_2)
assert None == result
assert result is None


@pytest.mark.order7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: It would make sense if @pytest.mark.order7 came before @pytest.mark.order8 if possible.

Expand All @@ -101,7 +98,8 @@ def test_retry_task():
name = "projects/{}/locations/{}/queues/{}".format(
TEST_PROJECT_ID, TEST_LOCATION, QUEUE_NAME[2])
result = snippets.retry_task(
TEST_PROJECT_ID, TEST_LOCATION, QUEUE_NAME[0], QUEUE_NAME[1], QUEUE_NAME[2])
TEST_PROJECT_ID, TEST_LOCATION, QUEUE_NAME[0], QUEUE_NAME[1],
QUEUE_NAME[2])
assert name in result.name

for i in range(3):
Expand Down