oncall-engine/engine/apps/grafana_plugin/tests/test_gcom_api_client.py
Innokentii Konstantinov 6d4e6f0108
Dev to main (#1129)
Release v1.1.16
Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
Co-authored-by: Vadim Stepanov <vadimkerr@gmail.com>
Co-authored-by: Rares Mardare <40542072+teodosii@users.noreply.github.com>
Co-authored-by: Tom Mitchell <klaue@live.com>
2023-01-12 18:40:47 +08:00

29 lines
1.1 KiB
Python

from unittest.mock import patch
import pytest
from apps.grafana_plugin.helpers.client import GcomAPIClient
class TestIsRbacEnabledForStack:
@pytest.mark.parametrize(
"gcom_api_response,expected",
[
(None, False),
({}, False),
({"config": {}}, False),
({"config": {"feature_toggles": {}}}, False),
({"config": {"feature_toggles": {"accessControlOnCall": "false"}}}, False),
({"config": {"feature_toggles": {"accessControlOnCall": "true"}}}, True),
],
)
@patch("apps.grafana_plugin.helpers.client.GcomAPIClient.api_get")
def test_it_returns_based_on_feature_toggle_value(
self, mocked_gcom_api_client_api_get, gcom_api_response, expected
):
stack_id = 5
mocked_gcom_api_client_api_get.return_value = (gcom_api_response, {"status_code": 200})
api_client = GcomAPIClient("someFakeApiToken")
assert api_client.is_rbac_enabled_for_stack(stack_id) == expected
assert mocked_gcom_api_client_api_get.called_once_with(f"instances/{stack_id}?config=true")