-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Changes from 1 commit
38d0ff7
5b8f559
7dd0ac5
faa3997
f6c9045
0d333d3
4cd4404
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# Copyright 2019 Google LLC All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import os | ||
import pytest | ||
import uuid | ||
|
||
import snippets | ||
|
||
TEST_PROJECT_ID = os.getenv('GCLOUD_PROJECT') | ||
TEST_LOCATION = os.getenv('TEST_QUEUE_LOCATION', 'us-central1') | ||
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( | ||
TEST_PROJECT_ID, TEST_LOCATION, QUEUE_NAME_2) | ||
result = snippets.create_queue( | ||
TEST_PROJECT_ID, TEST_LOCATION, QUEUE_NAME_1, QUEUE_NAME_2) | ||
assert name in result.name | ||
|
||
|
||
@pytest.mark.order2 | ||
def test_update_queue(): | ||
name = "projects/{}/locations/{}/queues/{}".format( | ||
TEST_PROJECT_ID, TEST_LOCATION, QUEUE_NAME_1) | ||
result = snippets.update_queue( | ||
TEST_PROJECT_ID, TEST_LOCATION, QUEUE_NAME_1) | ||
assert name in result.name | ||
|
||
|
||
@pytest.mark.order3 | ||
def test_create_task(): | ||
name = "projects/{}/locations/{}/queues/{}".format( | ||
TEST_PROJECT_ID, TEST_LOCATION, QUEUE_NAME_1) | ||
result = snippets.create_task( | ||
TEST_PROJECT_ID, TEST_LOCATION, QUEUE_NAME_1) | ||
assert name in result.name | ||
|
||
|
||
@pytest.mark.order4 | ||
def test_create_task_with_data(): | ||
name = "projects/{}/locations/{}/queues/{}".format( | ||
TEST_PROJECT_ID, TEST_LOCATION, QUEUE_NAME_1) | ||
result = snippets.create_tasks_with_data( | ||
TEST_PROJECT_ID, TEST_LOCATION, QUEUE_NAME_1) | ||
assert name in result.name | ||
|
||
|
||
@pytest.mark.order5 | ||
def test_create_task_with_name(): | ||
name = "projects/{}/locations/{}/queues/{}".format( | ||
TEST_PROJECT_ID, TEST_LOCATION, QUEUE_NAME_1) | ||
result = snippets.create_task_with_name( | ||
TEST_PROJECT_ID, TEST_LOCATION, QUEUE_NAME_1, 'foo') | ||
assert name in result.name | ||
|
||
|
||
@pytest.mark.order6 | ||
def test_delete_task(): | ||
name = "projects/{}/locations/{}/queues/{}".format( | ||
TEST_PROJECT_ID, TEST_LOCATION, QUEUE_NAME_1) | ||
result = snippets.delete_task( | ||
TEST_PROJECT_ID, TEST_LOCATION, QUEUE_NAME_1) | ||
assert name in result.name | ||
|
||
|
||
@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 | ||
|
||
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 | ||
|
||
|
||
@pytest.mark.order7 | ||
def test_retry_task(): | ||
QUEUE_NAME = [] | ||
for i in range(3): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Like Otherwise, we may break the tests if we change L95 without changing L105 vice versa. |
||
QUEUE_NAME.append("queue-{}".format(uuid.uuid4())) | ||
|
||
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]) | ||
assert name in result.name | ||
|
||
for i in range(3): | ||
snippets.delete_queue( | ||
TEST_PROJECT_ID, TEST_LOCATION, QUEUE_NAME[i]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this line could be more readable with named parameters project=TEST_PROJECT_ID, location=TEST_LOCATION, queue=QUEUE_NAME[i] |
There was a problem hiding this comment.
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.