def test_async_detect_document(capsys): storage_client = storage.Client() bucket = storage_client.get_bucket(BUCKET) assert len(list(bucket.list_blobs(prefix=OUTPUT_PREFIX))) == 0 detect.async_detect_document(gcs_source_uri=GCS_SOURCE_URI, gcs_destination_uri=GCS_DESTINATION_URI) out, _ = capsys.readouterr() assert 'Hodge conjecture' in out assert len(list(bucket.list_blobs(prefix=OUTPUT_PREFIX))) == 3 for blob in bucket.list_blobs(prefix=OUTPUT_PREFIX): blob.delete()
def test_async_detect_document(capsys): storage_client = storage.Client() bucket = storage_client.get_bucket(BUCKET) assert len(list(bucket.list_blobs(prefix=OUTPUT_PREFIX))) == 0 detect.async_detect_document( gcs_source_uri=GCS_SOURCE_URI, gcs_destination_uri=GCS_DESTINATION_URI) out, _ = capsys.readouterr() assert 'Hodge conjecture' in out assert len(list(bucket.list_blobs(prefix=OUTPUT_PREFIX))) == 3 for blob in bucket.list_blobs(prefix=OUTPUT_PREFIX): blob.delete()
def test_async_detect_document(capsys): storage_client = storage.Client() bucket = storage_client.get_bucket(BUCKET) if len(list(bucket.list_blobs(prefix=OUTPUT_PREFIX))) > 0: for blob in bucket.list_blobs(prefix=OUTPUT_PREFIX): blob.delete() assert len(list(bucket.list_blobs(prefix=OUTPUT_PREFIX))) == 0 uri = 'gs://{}/vision/document/custom_0773375000.pdf'.format(ASSET_BUCKET) detect.async_detect_document(gcs_source_uri=uri, gcs_destination_uri=GCS_DESTINATION_URI) out, _ = capsys.readouterr() assert 'OIL, GAS AND MINERAL LEASE' in out assert len(list(bucket.list_blobs(prefix=OUTPUT_PREFIX))) > 0 for blob in bucket.list_blobs(prefix=OUTPUT_PREFIX): blob.delete() assert len(list(bucket.list_blobs(prefix=OUTPUT_PREFIX))) == 0