def test_send_to_device(capsys): manager.create_iot_topic(project_id, topic_id) manager.open_registry(service_account_json, project_id, cloud_region, pubsub_topic, registry_id) manager.create_unauth_device(service_account_json, project_id, cloud_region, registry_id, device_id) gcs_to_device.send_to_device(gcs_bucket, gcs_file_name, destination_file_name, project_id, cloud_region, registry_id, device_id, service_account_json) manager.delete_device(service_account_json, project_id, cloud_region, registry_id, device_id) manager.delete_registry(service_account_json, project_id, cloud_region, registry_id) pubsub_client = pubsub.PublisherClient() topic_path = pubsub_client.topic_path(project_id, topic_id) pubsub_client.delete_topic(topic_path) out, _ = capsys.readouterr() assert 'Successfully sent file to device' in out
def test_topic(): topic = manager.create_iot_topic(topic_id) yield topic if topic.exists(): topic.delete()
def test_topic(): topic = manager.create_iot_topic(topic_id) yield topic if topic.exists(): topic.delete()
def test_topic(): topic = manager.create_iot_topic(project_id, topic_id) yield topic pubsub_client = pubsub.PublisherClient() topic_path = pubsub_client.topic_path(project_id, topic_id) pubsub_client.delete_topic(topic_path)
def test_send_to_device(capsys): manager.create_iot_topic(project_id, topic_id) manager.open_registry( service_account_json, project_id, cloud_region, pubsub_topic, registry_id) manager.create_unauth_device( service_account_json, project_id, cloud_region, registry_id, device_id) gcs_to_device.send_to_device( gcs_bucket, gcs_file_name, destination_file_name, project_id, cloud_region, registry_id, device_id, service_account_json) manager.delete_device( service_account_json, project_id, cloud_region, registry_id, device_id) manager.delete_registry( service_account_json, project_id, cloud_region, registry_id) pubsub_client = pubsub.PublisherClient() topic_path = pubsub_client.topic_path(project_id, topic_id) pubsub_client.delete_topic(topic_path) out, _ = capsys.readouterr() assert 'Successfully sent file to device' in out
def test_get_state(capsys): manager.create_iot_topic(project_id, topic_id) manager.open_registry( service_account_json, project_id, cloud_region, pubsub_topic, registry_id) manager.create_unauth_device( service_account_json, project_id, cloud_region, registry_id, device_id) gcs_to_device.get_state( service_account_json, project_id, cloud_region, registry_id, device_id) manager.delete_device( service_account_json, project_id, cloud_region, registry_id, device_id) manager.delete_registry( service_account_json, project_id, cloud_region, registry_id) pubsub_client = pubsub.PublisherClient() topic_path = pubsub_client.topic_path(project_id, topic_id) pubsub_client.delete_topic(topic_path) out, _ = capsys.readouterr() assert 'Id' in out assert 'Config' in out
def test_get_state(capsys): manager.create_iot_topic(project_id, topic_id) manager.open_registry(service_account_json, project_id, cloud_region, pubsub_topic, registry_id) manager.create_unauth_device(service_account_json, project_id, cloud_region, registry_id, device_id) gcs_to_device.get_state(service_account_json, project_id, cloud_region, registry_id, device_id) manager.delete_device(service_account_json, project_id, cloud_region, registry_id, device_id) manager.delete_registry(service_account_json, project_id, cloud_region, registry_id) pubsub_client = pubsub.PublisherClient() topic_path = pubsub_client.topic_path(project_id, topic_id) pubsub_client.delete_topic(topic_path) out, _ = capsys.readouterr() assert 'Id' in out assert 'Config' in out
def test_topic(): pubsub_client = pubsub.PublisherClient() try: topic = manager.create_iot_topic(project_id, topic_id) except AlreadyExists as e: print("The topic already exists, detail: {}".format(str(e))) # Ignore the error, fetch the topic topic = pubsub_client.get_topic( pubsub_client.topic_path(project_id, topic_id)) yield topic topic_path = pubsub_client.topic_path(project_id, topic_id) try: pubsub_client.delete_topic(topic_path) except NotFound as e: # We ignore this case. print("The topic doesn't exist: detail: {}".format(str(e)))