diff --git a/iam/api-client/access_test.py b/iam/api-client/access_test.py index 838468467879..7df4d8a113ad 100644 --- a/iam/api-client/access_test.py +++ b/iam/api-client/access_test.py @@ -13,15 +13,16 @@ # limitations under the License. import os -import pytest import uuid from googleapiclient import errors +import pytest from retrying import retry import access import service_accounts + # Setting up variables for testing GCLOUD_PROJECT = os.environ["GCLOUD_PROJECT"] diff --git a/iam/api-client/custom_roles_test.py b/iam/api-client/custom_roles_test.py index 192141104767..5d2252235434 100644 --- a/iam/api-client/custom_roles_test.py +++ b/iam/api-client/custom_roles_test.py @@ -13,11 +13,13 @@ # limitations under the License. import os -import pytest import uuid -import custom_roles import googleapiclient.errors +import pytest + +import custom_roles + GCLOUD_PROJECT = os.environ["GCLOUD_PROJECT"] diff --git a/iot/api-client/codelabs/gateway.py b/iot/api-client/codelabs/gateway.py index c5bc291a3602..0fd5e3cac0aa 100644 --- a/iot/api-client/codelabs/gateway.py +++ b/iot/api-client/codelabs/gateway.py @@ -143,7 +143,7 @@ def on_publish(unused_client, userdata, mid): def on_subscribe(unused_client, unused_userdata, mid, granted_qos): - print('on_subscribe: mid {}, qos {granted_qos}'.format(mid)) + print('on_subscribe: mid {}, qos {}'.format(mid, granted_qos)) try: client_addr, response = gateway_state.pending_subscribes[mid] udpSerSock.sendto(response.encode(), client_addr) diff --git a/iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py b/iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py index c04a2b9e1af8..f76033d3918e 100644 --- a/iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py +++ b/iot/api-client/end_to_end_example/cloudiot_pubsub_example_server.py @@ -43,9 +43,9 @@ import time from google.cloud import pubsub +from google.oauth2 import service_account from googleapiclient import discovery from googleapiclient.errors import HttpError -from google.oauth2 import service_account API_SCOPES = ['https://www.googleapis.com/auth/cloud-platform'] diff --git a/iot/api-client/gcs_file_to_device/gcs_send_to_device_test.py b/iot/api-client/gcs_file_to_device/gcs_send_to_device_test.py index a347465d13a0..c3309e89f7dc 100644 --- a/iot/api-client/gcs_file_to_device/gcs_send_to_device_test.py +++ b/iot/api-client/gcs_file_to_device/gcs_send_to_device_test.py @@ -19,17 +19,17 @@ from google.cloud import pubsub from google.cloud import storage - -# Add manager for bootstrapping device registry / device for testing -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'manager')) # noqa -import manager - import mock import pytest import requests import gcs_send_to_device as gcs_to_device +# Add manager for bootstrapping device registry / device for testing +sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'manager')) # noqa +import manager # noqa + + gcs_bucket = os.environ['CLOUD_STORAGE_BUCKET'] project_id = os.environ['GCLOUD_PROJECT'] service_account_json = os.environ['GOOGLE_APPLICATION_CREDENTIALS'] diff --git a/iot/api-client/http_example/cloudiot_http_example_test.py b/iot/api-client/http_example/cloudiot_http_example_test.py index 0ab22e3edfde..8497d1ffb334 100644 --- a/iot/api-client/http_example/cloudiot_http_example_test.py +++ b/iot/api-client/http_example/cloudiot_http_example_test.py @@ -16,15 +16,14 @@ import time from google.cloud import pubsub - -# Add manager for bootstrapping device registry / device for testing -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'manager')) # noqa -import manager - import pytest import cloudiot_http_example +# Add manager for bootstrapping device registry / device for testing +sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'manager')) # noqa +import manager # noqa + cloud_region = 'us-central1' device_id_template = 'test-device-{}' diff --git a/iot/api-client/manager/manager_test.py b/iot/api-client/manager/manager_test.py index 175f04753a94..20bac093a5f2 100644 --- a/iot/api-client/manager/manager_test.py +++ b/iot/api-client/manager/manager_test.py @@ -18,13 +18,14 @@ import time import uuid -# Add command receiver for bootstrapping device registry / device for testing -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'mqtt_example')) # noqa from google.cloud import pubsub import pytest -import manager -import cloudiot_mqtt_example +# Add command receiver for bootstrapping device registry / device for testing +sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'mqtt_example')) # noqa +import cloudiot_mqtt_example # noqa +import manager # noqa + cloud_region = 'us-central1' device_id_template = 'test-device-{}' diff --git a/iot/api-client/mqtt_example/cloudiot_mqtt_example_test.py b/iot/api-client/mqtt_example/cloudiot_mqtt_example_test.py index 50b6accd4134..0fd06f7d9427 100644 --- a/iot/api-client/mqtt_example/cloudiot_mqtt_example_test.py +++ b/iot/api-client/mqtt_example/cloudiot_mqtt_example_test.py @@ -18,14 +18,15 @@ import pytest -# Add manager for bootstrapping device registry / device for testing -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'manager')) # noqa -import cloudiot_mqtt_example -import manager from fixtures import test_topic # noqa from fixtures import test_registry_id # noqa from fixtures import test_device_id # noqa from fixtures import device_and_gateways # noqa +# Add manager for bootstrapping device registry / device for testing +sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'manager')) # noqa +import cloudiot_mqtt_example # noqa +import manager # noqa + cloud_region = 'us-central1' ca_cert_path = 'resources/roots.pem' diff --git a/iot/api-client/mqtt_example/cloudiot_mqtt_image.py b/iot/api-client/mqtt_example/cloudiot_mqtt_image.py index 60d7ded3e255..210b17deef2e 100644 --- a/iot/api-client/mqtt_example/cloudiot_mqtt_image.py +++ b/iot/api-client/mqtt_example/cloudiot_mqtt_image.py @@ -25,7 +25,7 @@ # Add manager as library sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'manager')) # noqa -import cloudiot_mqtt_example +import cloudiot_mqtt_example # noqa # [START iot_mqtt_image] diff --git a/iot/api-client/mqtt_example/cloudiot_mqtt_image_test.py b/iot/api-client/mqtt_example/cloudiot_mqtt_image_test.py index 2a41857982ff..5ee457c51391 100644 --- a/iot/api-client/mqtt_example/cloudiot_mqtt_image_test.py +++ b/iot/api-client/mqtt_example/cloudiot_mqtt_image_test.py @@ -16,13 +16,13 @@ import sys # Add manager as library -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'manager')) # noqa -import cloudiot_mqtt_image -import manager -from fixtures import test_topic # noqa -from fixtures import test_subscription # noqa -from fixtures import test_registry_id # noqa -from fixtures import test_device_id # noqa +sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'manager')) # noqa +import cloudiot_mqtt_image # noqa +import manager # noqa +from fixtures import test_topic # noqa +from fixtures import test_subscription # noqa +from fixtures import test_registry_id # noqa +from fixtures import test_device_id # noqa cloud_region = 'us-central1' diff --git a/iot/api-client/mqtt_example/fixtures.py b/iot/api-client/mqtt_example/fixtures.py index 4fc7be9aa7e2..d78f72001c22 100644 --- a/iot/api-client/mqtt_example/fixtures.py +++ b/iot/api-client/mqtt_example/fixtures.py @@ -18,15 +18,15 @@ import uuid import backoff -from googleapiclient.errors import HttpError -from google.cloud import pubsub from google.api_core.exceptions import AlreadyExists from google.api_core.exceptions import NotFound +from google.cloud import pubsub +from googleapiclient.errors import HttpError import pytest # Add manager as library sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'manager')) # noqa -import manager +import manager # noqa cloud_region = 'us-central1' diff --git a/iot/api-client/mqtt_example/gateway_demo.py b/iot/api-client/mqtt_example/gateway_demo.py index 8e2bbd44d15c..61c4311e3ebd 100644 --- a/iot/api-client/mqtt_example/gateway_demo.py +++ b/iot/api-client/mqtt_example/gateway_demo.py @@ -21,9 +21,9 @@ import time sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'manager')) # noqa +import cloudiot_mqtt_example # noqa +import manager # noqa -import cloudiot_mqtt_example -import manager logging.getLogger('googleapiclient.discovery_cache').setLevel(logging.CRITICAL)