oncall-engine/engine/apps/schedules/tests/factories.py
Joey Orlando 74b919ee3e
shift swap requests model + CRUD endpoints (#2597)
# What this PR does

This PR should allow us to start working on _most_ of the remaining
tasks for this feature set.
- Adds a basic `ShiftSwapRequest` model + CRUD endpoints. 
- Adds a `POST /api/internal/v1/shift_swaps/<id>/take` endpoint which
allows a benefactor to take a request (only when certain conditions
about the ssr are met)

Closes #2587 

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required) will be done in #2589
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required) (will update once we ship the finalized feature set)
2023-07-21 19:35:19 +00:00

48 lines
1.2 KiB
Python

import factory
from apps.schedules.models import (
CustomOnCallShift,
OnCallScheduleCalendar,
OnCallScheduleICal,
OnCallScheduleWeb,
ShiftSwapRequest,
)
from common.utils import UniqueFaker
class OnCallScheduleFactory(factory.DjangoModelFactory):
name = UniqueFaker("sentence", nb_words=2)
@classmethod
def get_factory_for_class(cls, klass):
factory_classes = OnCallScheduleFactory.__subclasses__()
for factory_class in factory_classes:
if issubclass(klass, factory_class._meta.model):
return factory_class
class OnCallScheduleICalFactory(OnCallScheduleFactory):
class Meta:
model = OnCallScheduleICal
class OnCallScheduleCalendarFactory(OnCallScheduleFactory):
class Meta:
model = OnCallScheduleCalendar
class OnCallScheduleWebFactory(OnCallScheduleFactory):
class Meta:
model = OnCallScheduleWeb
class CustomOnCallShiftFactory(factory.DjangoModelFactory):
name = UniqueFaker("sentence", nb_words=2)
class Meta:
model = CustomOnCallShift
class ShiftSwapRequestFactory(factory.DjangoModelFactory):
class Meta:
model = ShiftSwapRequest