Skip to content

Commit 1402189

Browse files
authored
fix: Update the integratationtest functionality (#22)
1 parent ec6f8c4 commit 1402189

File tree

5 files changed

+8
-20
lines changed

5 files changed

+8
-20
lines changed

.github/workflows/integrationtest.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Integrationtest
22

33
on:
4+
schedule:
5+
- cron: '0 23 * * 6'
46
push:
57
branches: [ main ]
68
pull_request:

grafana_api/other_http.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,9 @@ def renew_login_session_based_on_remember_cookie(self):
4949
Returns:
5050
None
5151
"""
52+
api_call: dict = Api(self.grafana_api_model).call_the_api(f"{APIEndpoints.LOGIN.value}/ping")
5253

53-
api_call: str = (
54-
Api(self.grafana_api_model)
55-
.call_the_api(f"{APIEndpoints.LOGIN.value}/ping")
56-
.data.decode("utf-8")
57-
)
58-
59-
if api_call != "Logged in":
54+
if api_call.get("message") != "Logged in":
6055
logging.error(f"Check the error: {api_call}.")
6156
raise Exception
6257
else:

tests/integrationtest/test_service_account.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ def test_lifecycle_service_account(self):
7575
service_account_all_migrated.get("serviceAccounts")[0].get("id")
7676
)
7777

78-
self.assertEqual(
79-
True, self.service_account.get_service_account_migration_status()
80-
)
81-
8278
token: dict = self.authentication.create_api_token("Test-migrated", "Viewer")
8379
self.service_account.migrate_api_key_to_service_account(token.get("id"))
8480
self.assertEqual(
@@ -88,16 +84,12 @@ def test_lifecycle_service_account(self):
8884
query="Test-migrated"
8985
)
9086

91-
self.service_account.revert_service_account_token_to_api_key(
92-
service_account_migrated.get("serviceAccounts")[0].get("id"),
93-
token.get("id"),
94-
)
9587
self.assertEqual(
96-
2, len(self.service_account.search_service_account().get("serviceAccounts"))
88+
3, len(self.service_account.search_service_account().get("serviceAccounts"))
9789
)
9890

9991
self.service_account.delete_service_account(service_account.get("id"))
92+
self.service_account.delete_service_account(service_account_migrated.get("serviceAccounts")[0].get("id"))
10093
self.assertEqual(
10194
1, len(self.service_account.search_service_account().get("serviceAccounts"))
10295
)
103-
self.authentication.delete_api_token(token.get("id"))

tests/integrationtest/test_team.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ def test_e_delete_team_member(self):
7979
self.team.delete_team_by_id(team_id)
8080

8181
def test_get_team_preferences(self):
82-
print(self.team.get_team_preferences(4))
8382
self.assertEqual(
8483
"tests", self.team.get_team_preferences(4).get("homeDashboardUID")
8584
)

tests/unittests/test_other_http.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_renew_login_session_based_on_remember_cookie(self, call_the_api_mock):
3232
model: APIModel = APIModel(host=MagicMock(), token=MagicMock())
3333
other_http: OtherHTTP = OtherHTTP(grafana_api_model=model)
3434

35-
call_the_api_mock.return_value.data = b"Logged in"
35+
call_the_api_mock.return_value = dict({"message": "Logged in"})
3636

3737
self.assertEqual(
3838
None, other_http.renew_login_session_based_on_remember_cookie()
@@ -45,7 +45,7 @@ def test_renew_login_session_based_on_remember_cookie_no_valid_result(
4545
model: APIModel = APIModel(host=MagicMock(), token=MagicMock())
4646
other_http: OtherHTTP = OtherHTTP(grafana_api_model=model)
4747

48-
call_the_api_mock.return_value.data = b""
48+
call_the_api_mock.return_value = dict()
4949

5050
with self.assertRaises(Exception):
5151
other_http.renew_login_session_based_on_remember_cookie()

0 commit comments

Comments
 (0)