Skip to content

Commit

Permalink
manual updates for the fixtures / comparators / factories
Browse files Browse the repository at this point in the history
  • Loading branch information
saponifi3d committed Sep 16, 2024
1 parent 37bb678 commit 2d789ea
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/sentry/backup/comparators.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,7 @@ def get_default_comparators() -> dict[str, list[JSONScrubbingComparator]]:
],
"sentry.userrole": [DateUpdatedComparator("date_updated")],
"sentry.userroleuser": [DateUpdatedComparator("date_updated")],
"workflow_engine.datacondition": [DateUpdatedComparator("date_updated", "date_added")],
"workflow_engine.datasource": [DateUpdatedComparator("date_updated", "date_added")],
"workflow_engine.datasourcedetector": [
DateUpdatedComparator("date_updated", "date_added")
Expand Down
10 changes: 9 additions & 1 deletion src/sentry/testutils/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
from sentry.utils import loremipsum
from sentry.utils.performance_issues.performance_problem import PerformanceProblem
from sentry.workflow_engine.models import (
DataCondition,
DataSource,
DataSourceDetector,
Detector,
Expand Down Expand Up @@ -2059,14 +2060,21 @@ def create_workflow(

@staticmethod
@assume_test_silo_mode(SiloMode.REGION)
def create_workflowaction(
def create_workflow_action(
workflow: Workflow | None = None,
**kwargs,
) -> WorkflowAction:
if workflow is None:
workflow = Factories.create_workflow()
return WorkflowAction.objects.create(workflow=workflow, **kwargs)

@staticmethod
@assume_test_silo_mode(SiloMode.REGION)
def create_data_condition(
**kwargs,
) -> DataCondition:
return DataCondition.objects.create(**kwargs)

@staticmethod
@assume_test_silo_mode(SiloMode.REGION)
def create_data_source(
Expand Down
12 changes: 8 additions & 4 deletions src/sentry/testutils/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
from sentry.users.models.identity import Identity, IdentityProvider
from sentry.users.models.user import User
from sentry.users.services.user import RpcUser
from sentry.workflow_engine.models import DataSource, Detector, Workflow


class Fixtures:
Expand Down Expand Up @@ -633,16 +634,19 @@ def create_dashboard_widget(self, *args, **kwargs):
def create_dashboard_widget_query(self, *args, **kwargs):
return Factories.create_dashboard_widget_query(*args, **kwargs)

def create_workflow(self, *args, **kwargs):
def create_workflow(self, *args, **kwargs) -> Workflow:
return Factories.create_workflow(*args, **kwargs)

def create_workflowaction(self, *args, **kwargs):
return Factories.create_workflowaction(*args, **kwargs)
def create_workflow_action(self, *args, **kwargs):
return Factories.create_workflow_action(*args, **kwargs)

def create_data_source(self, *args, **kwargs):
return Factories.create_data_source(*args, **kwargs)

def create_detector(self, *args, **kwargs):
def create_data_condition(self, *args, **kwargs):
return Factories.create_data_condition(*args, **kwargs)

def create_detector(self, *args, **kwargs) -> Detector:
return Factories.create_detector(*args, **kwargs)

def create_data_source_detector(self, *args, **kwargs):
Expand Down
11 changes: 6 additions & 5 deletions src/sentry/testutils/helpers/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,11 +610,12 @@ def create_exhaustive_organization(

workflow = self.create_workflow(organization=org)
self.create_workflowaction(workflow=workflow)
self.create_workflow(organization=org)
self.create_data_source_detector(
self.create_data_source(organization=org),
self.create_detector(organization=org),
)
detector = (self.create_detector(organization=org),)
data_source = self.create_data_source(organization=org)

self.create_data_source_detector(data_source, detector)
self.create_workflow_action(workflow=workflow)
self.create_data_condition(detector=detector)

return org

Expand Down

0 comments on commit 2d789ea

Please sign in to comment.