Skip to content

Commit ec6f8c4

Browse files
authored
fix: Adjust the checked error messages (#18)
* fix: Adjust the checked error messages
1 parent d0849ed commit ec6f8c4

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

Diff for: grafana_api/model.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Self = TypeVar("Self", bound="Route")
77

88
# The constant includes all necessary error messages that can occurs, if you establish a connection to the Grafana API.
9-
ERROR_MESSAGES: list = ["invalid API key"]
9+
ERROR_MESSAGES: list = ["invalid API key", "Expired API key"]
1010

1111

1212
class APIEndpoints(Enum):

Diff for: setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setuptools.setup(
1010
name="grafana-api-sdk",
11-
version="0.0.9",
11+
version="0.1.0",
1212
author="Pascal Zimmermann",
1313
author_email="[email protected]",
1414
description="A Grafana API SDK",

Diff for: tests/integrationtest/test_alerting.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import time
23
from unittest import TestCase
34

45
from grafana_api.model import (
@@ -120,8 +121,15 @@ def test_test_alertmanager_receivers(self):
120121
)
121122

122123
def test_get_prometheus_alerts(self):
123-
self.assertEqual("Test",
124-
self.alerting.get_prometheus_alerts().get("data").get("alerts")[0].get("labels").get("alertname"))
124+
MAX_TRIES: int = 3
125+
126+
for i in range(0, MAX_TRIES):
127+
if len(self.alerting.get_prometheus_alerts().get("data").get("alerts")) != 0:
128+
time.sleep(0.1 + i / 2)
129+
self.assertEqual("Test",
130+
self.alerting.get_prometheus_alerts().get("data").get("alerts")[0].get("labels").get("alertname"))
131+
elif i == MAX_TRIES:
132+
self.fail("Conditions not yet fulfilled.")
125133

126134
def test_get_prometheus_rules(self):
127135
self.assertEqual(

0 commit comments

Comments
 (0)