forked from Azure/azure-sdk-for-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle value types for results (Azure#20358)
* Handle value types for results * update test * lint * comprehension * more precis * fix test
- Loading branch information
1 parent
2067cef
commit 9e13708
Showing
4 changed files
with
45 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
sdk/monitor/azure-monitor-query/tests/test_logs_response.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from datetime import datetime | ||
import pytest | ||
import six | ||
import os | ||
|
||
from azure.identity import ClientSecretCredential | ||
from azure.monitor.query import LogsQueryClient | ||
|
||
def _credential(): | ||
credential = ClientSecretCredential( | ||
client_id = os.environ['AZURE_CLIENT_ID'], | ||
client_secret = os.environ['AZURE_CLIENT_SECRET'], | ||
tenant_id = os.environ['AZURE_TENANT_ID'] | ||
) | ||
return credential | ||
|
||
@pytest.mark.live_test_only | ||
def test_query_response_types(): | ||
credential = _credential() | ||
client = LogsQueryClient(credential) | ||
query = """AppRequests | | ||
summarize avgRequestDuration=avg(DurationMs) by bin(TimeGenerated, 10m), _ResourceId, Success, ItemCount, DurationMs""" | ||
|
||
# returns LogsQueryResult | ||
result = client.query(os.environ['LOG_WORKSPACE_ID'], query, timespan=None) | ||
assert isinstance(result.tables[0].rows[0][0], datetime) # TimeGenerated generated is a datetime | ||
assert isinstance(result.tables[0].rows[0][1], six.string_types) # _ResourceId generated is a string | ||
assert isinstance(result.tables[0].rows[0][2], bool) # Success generated is a bool | ||
assert isinstance(result.tables[0].rows[0][3], int) # ItemCount generated is a int | ||
assert isinstance(result.tables[0].rows[0][4], float) # DurationMs generated is a real | ||
|