Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyorlando committed Jun 10, 2024
1 parent c4477b0 commit 4352d99
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion engine/apps/grafana_plugin/tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_it_triggers_an_organization_sync_and_saves_the_grafana_token(
response = client.post(reverse("grafana-plugin:install"), format="json", **auth_headers)

assert response.status_code == status.HTTP_204_NO_CONTENT
assert mocked_sync_organization.called_once_with(organization)
assert mocked_sync_organization.assert_called_once_with(organization)

# make sure api token is saved on the org
organization.refresh_from_db()
Expand Down
26 changes: 13 additions & 13 deletions engine/apps/grafana_plugin/tests/test_self_hosted_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def test_it_properly_handles_errors_from_the_grafana_api(
url = reverse("grafana-plugin:self-hosted-install")
response = client.post(url, format="json", **make_self_hosted_install_header(GRAFANA_TOKEN))

assert mocked_grafana_api_client.called_once_with(api_url=GRAFANA_API_URL, api_token=GRAFANA_TOKEN)
assert mocked_grafana_api_client.return_value.check_token.called_once_with()
assert mocked_grafana_api_client.assert_called_once_with(api_url=GRAFANA_API_URL, api_token=GRAFANA_TOKEN)
assert mocked_grafana_api_client.return_value.check_token.assert_called_once_with()

assert response.status_code == status.HTTP_400_BAD_REQUEST
assert response.data["error"] == expected_error_msg
Expand Down Expand Up @@ -106,13 +106,13 @@ def test_if_organization_exists_it_is_updated(
url = reverse("grafana-plugin:self-hosted-install")
response = client.post(url, format="json", **make_self_hosted_install_header(GRAFANA_TOKEN))

assert mocked_grafana_api_client.called_once_with(api_url=GRAFANA_API_URL, api_token=GRAFANA_TOKEN)
assert mocked_grafana_api_client.return_value.check_token.called_once_with()
assert mocked_grafana_api_client.return_value.is_rbac_enabled_for_organization.called_once_with()
assert mocked_grafana_api_client.assert_called_once_with(api_url=GRAFANA_API_URL, api_token=GRAFANA_TOKEN)
assert mocked_grafana_api_client.return_value.check_token.assert_called_once_with()
assert mocked_grafana_api_client.return_value.is_rbac_enabled_for_organization.assert_called_once_with()

assert mocked_sync_organization.called_once_with(organization)
assert mocked_provision_plugin.called_once_with()
assert mocked_revoke_plugin.called_once_with()
assert mocked_sync_organization.assert_called_once_with(organization)
assert mocked_provision_plugin.assert_called_once_with()
assert mocked_revoke_plugin.assert_called_once_with()

assert response.status_code == status.HTTP_201_CREATED
assert response.data == {"error": None, **provision_plugin_response}
Expand Down Expand Up @@ -151,12 +151,12 @@ def test_if_organization_does_not_exist_it_is_created(

organization = Organization.objects.filter(stack_id=STACK_ID, org_id=ORG_ID).first()

assert mocked_grafana_api_client.called_once_with(api_url=GRAFANA_API_URL, api_token=GRAFANA_TOKEN)
assert mocked_grafana_api_client.return_value.check_token.called_once_with()
assert mocked_grafana_api_client.return_value.is_rbac_enabled_for_organization.called_once_with()
assert mocked_grafana_api_client.assert_called_once_with(api_url=GRAFANA_API_URL, api_token=GRAFANA_TOKEN)
assert mocked_grafana_api_client.return_value.check_token.assert_called_once_with()
assert mocked_grafana_api_client.return_value.is_rbac_enabled_for_organization.assert_called_once_with()

assert mocked_sync_organization.called_once_with(organization)
assert mocked_provision_plugin.called_once_with()
assert mocked_sync_organization.assert_called_once_with(organization)
assert mocked_provision_plugin.assert_called_once_with()
assert not mocked_revoke_plugin.called

assert response.status_code == status.HTTP_201_CREATED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def test_notify_by_provider_call_limits_warning(
phone_backend = PhoneBackend()
phone_backend._notify_by_provider_call(user, "some_message")

assert mock_add_call_limit_warning.called_once_with(2, "some_message")
assert mock_add_call_limit_warning.assert_called_once_with(2, "some_message")


@pytest.mark.django_db
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def test_notify_by_provider_sms_limits_warning(
phone_backend = PhoneBackend()
phone_backend._notify_by_provider_sms(user, "some_message")

assert mock_add_sms_limit_warning.called_once_with(2, "some_message")
assert mock_add_sms_limit_warning.assert_called_once_with(2, "some_message")


@pytest.mark.django_db
Expand Down
4 changes: 2 additions & 2 deletions engine/apps/slack/tests/test_scenario_steps/test_paging.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def test_trigger_paging_additional_responders(make_organization_and_user_with_sl
with patch.object(step._slack_client, "api_call"):
step.process_scenario(slack_user_identity, slack_team_identity, payload)

mock_direct_paging.called_once_with(organization, user, "The Message", team, [(user, True)])
mock_direct_paging.assert_called_once_with(organization, user, "The Message", team, [(user, True)])


@pytest.mark.django_db
Expand All @@ -315,7 +315,7 @@ def test_page_team(make_organization_and_user_with_slack_identities, make_team):
with patch.object(step._slack_client, "api_call"):
step.process_scenario(slack_user_identity, slack_team_identity, payload)

mock_direct_paging.called_once_with(organization, user, "The Message", team)
mock_direct_paging.assert_called_once_with(organization, user, "The Message", team)


@pytest.mark.django_db
Expand Down

0 comments on commit 4352d99

Please sign in to comment.