-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from kpetremann/crash_bad_char_metric_name
Crash bad char metric name
- Loading branch information
Showing
4 changed files
with
46 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Unit tests.""" |
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,15 @@ | ||
"""Tests of Prometheus normalization metrics.""" | ||
from mqtt_exporter.main import _normalize_prometheus_metric_name | ||
|
||
|
||
def test_normalize_prometheus_metric_name(): | ||
"""Test _normalize_prometheus_metric_name.""" | ||
tests = { | ||
"1234invalid": ":1234invalid", | ||
"valid1234": "valid1234", | ||
"_this_is_valid": "_this_is_valid", | ||
"not_so_valid%_name": "not_so_valid_name", | ||
} | ||
|
||
for candidate, wanted in tests.items(): | ||
assert _normalize_prometheus_metric_name(candidate) == wanted |