Update schedules endpoint to filter by numeric type
This commit is contained in:
parent
3f424cb0a0
commit
64570cc9fd
2 changed files with 6 additions and 4 deletions
|
|
@ -205,11 +205,11 @@ def test_get_list_schedules_by_type(
|
|||
},
|
||||
]
|
||||
|
||||
for expected, schedule_type in enumerate(("api", "ical", "web")):
|
||||
for schedule_type in range(3):
|
||||
url = reverse("api-internal:schedule-list") + "?type={}".format(schedule_type)
|
||||
response = client.get(url, format="json", **make_user_auth_headers(user, token))
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert response.json() == [expected_payload[expected]]
|
||||
assert response.json() == [expected_payload[schedule_type]]
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ from apps.api.serializers.schedule_polymorphic import (
|
|||
from apps.auth_token.auth import PluginAuthentication
|
||||
from apps.auth_token.constants import SCHEDULE_EXPORT_TOKEN_NAME
|
||||
from apps.auth_token.models import ScheduleExportAuthToken
|
||||
from apps.schedules.models import OnCallSchedule, OnCallScheduleCalendar, OnCallScheduleICal, OnCallScheduleWeb
|
||||
from apps.schedules.models import OnCallSchedule
|
||||
from apps.slack.models import SlackChannel
|
||||
from apps.slack.tasks import update_slack_user_group_for_schedules
|
||||
from common.api_helpers.exceptions import BadRequest, Conflict
|
||||
|
|
@ -42,7 +42,9 @@ EVENTS_FILTER_BY_ROTATION = "rotation"
|
|||
EVENTS_FILTER_BY_OVERRIDE = "override"
|
||||
EVENTS_FILTER_BY_FINAL = "final"
|
||||
|
||||
SCHEDULE_TYPE_TO_CLASS = {"api": OnCallScheduleCalendar, "ical": OnCallScheduleICal, "web": OnCallScheduleWeb}
|
||||
SCHEDULE_TYPE_TO_CLASS = {
|
||||
str(num_type): cls for cls, num_type in PolymorphicScheduleSerializer.SCHEDULE_CLASS_TO_TYPE.items()
|
||||
}
|
||||
|
||||
|
||||
class ScheduleView(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue