Skip to content

Commit

Permalink
Update fixtures / factories /tests
Browse files Browse the repository at this point in the history
  • Loading branch information
saponifi3d committed Sep 18, 2024
1 parent ee046d1 commit a80d29a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/sentry/backup/comparators.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,9 @@ 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.dataconditiongroup": [
DateUpdatedComparator("date_updated", "date_added")
],
"workflow_engine.datasource": [DateUpdatedComparator("date_updated", "date_added")],
"workflow_engine.datasourcedetector": [
DateUpdatedComparator("date_updated", "date_added")
Expand Down
8 changes: 8 additions & 0 deletions src/sentry/testutils/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
from sentry.utils.performance_issues.performance_problem import PerformanceProblem
from sentry.workflow_engine.models import (
DataCondition,
DataConditionGroup,
DataSource,
DataSourceDetector,
Detector,
Expand Down Expand Up @@ -2081,6 +2082,13 @@ def create_data_condition(
) -> DataCondition:
return DataCondition.objects.create(**kwargs)

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

@staticmethod
@assume_test_silo_mode(SiloMode.REGION)
def create_data_source(
Expand Down
13 changes: 11 additions & 2 deletions src/sentry/testutils/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@
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
from sentry.workflow_engine.models import (
DataCondition,
DataConditionGroup,
DataSource,
Detector,
Workflow,
)


class Fixtures:
Expand Down Expand Up @@ -643,9 +649,12 @@ def create_workflow_action(self, *args, **kwargs):
def create_data_source(self, *args, **kwargs) -> DataSource:
return Factories.create_data_source(*args, **kwargs)

def create_data_condition(self, *args, **kwargs):
def create_data_condition(self, *args, **kwargs) -> DataCondition:
return Factories.create_data_condition(*args, **kwargs)

def create_data_condition_group(self, *args, **kwargs) -> DataConditionGroup:
return Factories.create_data_condition_group(*args, **kwargs)

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

Expand Down
9 changes: 8 additions & 1 deletion src/sentry/testutils/helpers/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,14 @@ def create_exhaustive_organization(

self.create_data_source_detector(data_source, detector)
self.create_workflow_action(workflow=workflow)
self.create_data_condition(detector=detector)
condition_group = self.create_data_condition_group(detector=detector)
self.create_data_condition(
condition="test",
condition_result="True",
threshold=0.5,
type="gte",
condition_group=condition_group,
)

return org

Expand Down

0 comments on commit a80d29a

Please sign in to comment.