def test_timeseries_with_overrides(): data_source = 'dummy data source' targets = ['dummy_prom_query'] title = 'dummy title' overrides = [ { "matcher": { "id": "byName", "options": "min" }, "properties": [ { "id": "custom.fillBelowTo", "value": "min" }, { "id": "custom.lineWidth", "value": 0 } ] } ] timeseries = G.TimeSeries( dataSource=data_source, targets=targets, title=title, overrides=overrides, ) data = timeseries.to_json_data() assert data["targets"] == targets assert data["datasource"] == data_source assert data["title"] == title assert data["fieldConfig"]["overrides"] == overrides
def test_timeseries(): data_source = 'dummy data source' targets = ['dummy_prom_query'] title = 'dummy title' timeseries = G.TimeSeries(data_source, targets, title) data = timeseries.to_json_data() assert data['targets'] == targets assert data['datasource'] == data_source assert data['title'] == title assert data['fieldConfig']['overrides'] == []
def test_serialization_azure_metrics_target(): """Serializing a graph doesn't explode.""" graph = G.TimeSeries( title="Test Azure Monitor", dataSource="default", targets=[ A.AzureMonitorMetricsTarget( aggregation="Total", metricDefinition="Microsoft.Web/sites", metricName="Requests", metricNamespace="Microsoft.Web/sites", resourceGroup="test-grafana", resourceName="test-grafana", subscription="3a680d1a-9310-4667-9e6a-9fcd2ecddd86", refId="Requests", ), ], ) stream = StringIO() _gen.write_dashboard(graph, stream) assert stream.getvalue() != ""