|
@@ -92,7 +92,7 @@ class CustomRulesGetEndpoint(APITestCase):
|
|
|
self.organization.slug,
|
|
|
qs_params={
|
|
|
"query": "environment:prod",
|
|
|
- "project": [self.known_projects[1].id],
|
|
|
+ "project": [proj.id for proj in self.known_projects[1:3]],
|
|
|
},
|
|
|
)
|
|
|
|
|
@@ -127,7 +127,7 @@ class CustomRulesGetEndpoint(APITestCase):
|
|
|
|
|
|
def test_finds_org_condition(self):
|
|
|
"""
|
|
|
- A request for either any project of org will find an org rule ( if condition matches)
|
|
|
+ A request for org will find an org rule ( if condition matches)
|
|
|
"""
|
|
|
|
|
|
# finds projects in the org rule
|
|
@@ -136,7 +136,7 @@ class CustomRulesGetEndpoint(APITestCase):
|
|
|
self.organization.slug,
|
|
|
qs_params={
|
|
|
"query": "environment:dev",
|
|
|
- "project": [self.known_projects[1].id],
|
|
|
+ "project": [],
|
|
|
},
|
|
|
)
|
|
|
assert resp.status_code == 200
|
|
@@ -177,7 +177,7 @@ class CustomRulesGetEndpoint(APITestCase):
|
|
|
self.organization.slug,
|
|
|
qs_params={
|
|
|
"query": "environment:prod",
|
|
|
- "project": [self.known_projects[1].id],
|
|
|
+ "project": [project.id for project in self.known_projects[1:3]],
|
|
|
},
|
|
|
)
|
|
|
assert resp.status_code == 200
|
|
@@ -212,7 +212,6 @@ class CustomRulesEndpoint(APITestCase):
|
|
|
"query": "event.type:transaction",
|
|
|
"projects": [self.project.id],
|
|
|
"period": "1h",
|
|
|
- "overrideExisting": True,
|
|
|
}
|
|
|
with Feature({"organizations:investigation-bias": True}):
|
|
|
resp = self.get_response(self.organization.slug, raw_data=request_data)
|
|
@@ -241,7 +240,6 @@ class CustomRulesEndpoint(APITestCase):
|
|
|
"query": "",
|
|
|
"projects": [self.project.id],
|
|
|
"period": "1h",
|
|
|
- "overrideExisting": True,
|
|
|
}
|
|
|
with Feature({"organizations:investigation-bias": True}):
|
|
|
resp = self.get_response(self.organization.slug, raw_data=request_data)
|
|
@@ -267,16 +265,15 @@ class CustomRulesEndpoint(APITestCase):
|
|
|
|
|
|
def test_updates_existing(self):
|
|
|
"""
|
|
|
- Test that the endpoint updates an existing rule if the same rule condition is given
|
|
|
+ Test that the endpoint updates an existing rule if the same rule condition and projects is given
|
|
|
|
|
|
The rule id should be the same
|
|
|
- The period and the projects should be updated
|
|
|
+ The period should be updated
|
|
|
"""
|
|
|
request_data = {
|
|
|
"query": "event.type:transaction",
|
|
|
"projects": [self.project.id],
|
|
|
"period": "1h",
|
|
|
- "overrideExisting": True,
|
|
|
}
|
|
|
|
|
|
# create rule
|
|
@@ -294,9 +291,8 @@ class CustomRulesEndpoint(APITestCase):
|
|
|
|
|
|
request_data = {
|
|
|
"query": "event.type:transaction",
|
|
|
- "projects": [self.second_project.id],
|
|
|
+ "projects": [self.project.id],
|
|
|
"period": "2h",
|
|
|
- "overrideExisting": True,
|
|
|
}
|
|
|
|
|
|
# update existing rule
|
|
@@ -311,8 +307,7 @@ class CustomRulesEndpoint(APITestCase):
|
|
|
assert end_date - start_date >= timedelta(hours=2)
|
|
|
|
|
|
projects = data["projects"]
|
|
|
- assert self.project.id in projects
|
|
|
- assert self.second_project.id in projects
|
|
|
+ assert projects == [self.project.id]
|
|
|
|
|
|
new_rule_id = data["ruleId"]
|
|
|
assert rule_id == new_rule_id
|
|
@@ -325,7 +320,6 @@ class CustomRulesEndpoint(APITestCase):
|
|
|
"query": "event.type:transaction",
|
|
|
"projects": [self.project.id],
|
|
|
"period": "1h",
|
|
|
- "overrideExisting": True,
|
|
|
}
|
|
|
with Feature({"organizations:investigation-bias": False}):
|
|
|
resp = self.get_response(self.organization.slug, raw_data=request_data)
|