oncall-engine/engine/apps/slack/tests/conftest.py
Vadim Stepanov 0d7352a17b
Fix handling Slack rate limits (#2991)
## Which issue(s) this PR fixes

https://github.com/grafana/oncall-private/issues/2156

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-09-07 11:25:29 +00:00

32 lines
873 B
Python

import typing
import pytest
from rest_framework import status
from slack_sdk.web import SlackResponse
def build_slack_response(
data: dict[str, typing.Any],
status_code: int = status.HTTP_200_OK,
headers: typing.Optional[dict[str, typing.Any]] = None,
):
return SlackResponse(
client=None,
http_verb="POST",
api_url="test",
req_args={},
data=data,
headers=headers if headers else {},
status_code=status_code,
)
@pytest.fixture
def get_slack_team_and_slack_user(make_organization_and_user_with_slack_identities):
def _make_slack_team_and_slack_user(organization, user):
slack_team_identity = organization.slack_team_identity
slack_user_identity = user.slack_user_identity
return slack_team_identity, slack_user_identity
return _make_slack_team_and_slack_user