# What this PR does - Adds [`mypy` static type checking](https://mypy-lang.org/) to our CI pipeline. Currently there is still a **ton** of errors being returned by the tool, as we'll need to fix pre-existing errors. I think we can slowly chip away at these errors in small PRs, doing them all in one large PR is likely very risky. - Also, this PR starts chipping away at one of the main type errors that we have which is accessing the `datetime` class (from the `datetime` library) or `timedelta` function on the `django.utils.timezone` module. Basically we should be instead accessing these two objects from the native `datetime` module. This makes sense because the [`__all__` attribute](https://github.com/django/django/blob/main/django/utils/timezone.py#L14-L30) in `django.utils.timezone` does not re-export `datetime` or `timedelta`. - splits `engine` dependencies out into `requirements.txt` and `requirements-dev.txt` ## Checklist - [ ] Unit, integration, and e2e (if applicable) tests updated (N/A) - [ ] Documentation added (or `pr:no public docs` PR label added if not required) (N/A) - [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required) (N/A)
81 lines
1.7 KiB
Python
81 lines
1.7 KiB
Python
import factory
|
|
|
|
from apps.alerts.models import (
|
|
Alert,
|
|
AlertGroup,
|
|
AlertGroupLogRecord,
|
|
AlertReceiveChannel,
|
|
ChannelFilter,
|
|
CustomButton,
|
|
EscalationChain,
|
|
EscalationPolicy,
|
|
Invitation,
|
|
ResolutionNote,
|
|
ResolutionNoteSlackMessage,
|
|
)
|
|
from common.utils import UniqueFaker
|
|
|
|
|
|
class AlertReceiveChannelFactory(factory.DjangoModelFactory):
|
|
# integration = AlertReceiveChannel.INTEGRATION_GRAFANA
|
|
verbal_name = factory.Faker("sentence", nb_words=2)
|
|
|
|
class Meta:
|
|
model = AlertReceiveChannel
|
|
|
|
|
|
class ChannelFilterFactory(factory.DjangoModelFactory):
|
|
class Meta:
|
|
model = ChannelFilter
|
|
|
|
|
|
class EscalationChainFactory(factory.DjangoModelFactory):
|
|
name = UniqueFaker("word")
|
|
|
|
class Meta:
|
|
model = EscalationChain
|
|
|
|
|
|
class EscalationPolicyFactory(factory.DjangoModelFactory):
|
|
class Meta:
|
|
model = EscalationPolicy
|
|
|
|
|
|
class AlertFactory(factory.DjangoModelFactory):
|
|
class Meta:
|
|
model = Alert
|
|
|
|
|
|
class AlertGroupFactory(factory.DjangoModelFactory):
|
|
class Meta:
|
|
model = AlertGroup
|
|
|
|
|
|
class AlertGroupLogRecordFactory(factory.DjangoModelFactory):
|
|
class Meta:
|
|
model = AlertGroupLogRecord
|
|
|
|
|
|
class ResolutionNoteFactory(factory.DjangoModelFactory):
|
|
message_text = factory.Faker("sentence", nb_words=5)
|
|
|
|
class Meta:
|
|
model = ResolutionNote
|
|
|
|
|
|
class ResolutionNoteSlackMessageFactory(factory.DjangoModelFactory):
|
|
class Meta:
|
|
model = ResolutionNoteSlackMessage
|
|
|
|
|
|
class CustomActionFactory(factory.DjangoModelFactory):
|
|
webhook = factory.Faker("url")
|
|
name = UniqueFaker("word")
|
|
|
|
class Meta:
|
|
model = CustomButton
|
|
|
|
|
|
class InvitationFactory(factory.DjangoModelFactory):
|
|
class Meta:
|
|
model = Invitation
|