| 1 |
from io import BytesIO |
| 2 |
|
| 3 |
from azure.kusto.ingest import FileDescriptor, BlobDescriptor, StreamDescriptor |
| 4 |
from azure.kusto.ingest.ingestion_properties import IngestionProperties |
| 5 |
|
| 6 |
|
| 7 |
def test_get_tracing_attributes(): |
| 8 |
ingestion_properties = IngestionProperties("database_test", "table_test") |
| 9 |
assert {"database": "database_test", "table": "table_test"} == ingestion_properties.get_tracing_attributes() |
| 10 |
|
| 11 |
dummy_stream = BytesIO(b"dummy") |
| 12 |
stream = StreamDescriptor(dummy_stream) |
| 13 |
dummy_path = "dummy" |
| 14 |
blob = BlobDescriptor(dummy_path) |
| 15 |
file = FileDescriptor(dummy_path) |
| 16 |
|
| 17 |
descriptors = [stream, blob, file] |
| 18 |
keynames = [{"stream_name", "source_id"}, {"blob_uri", "source_id"}, {"file_path", "source_id"}] |
| 19 |
for i in range(len(descriptors)): |
| 20 |
attributes = descriptors[i].get_tracing_attributes() |
| 21 |
assert isinstance(attributes, dict) |
| 22 |
for key, val in attributes.items(): |
| 23 |
assert key in keynames[i] |
| 24 |
assert isinstance(val, str) |
| 25 |
for key in keynames[i]: |
| 26 |
assert key in attributes.keys() |