Skip to content

Commit

Permalink
Fix timeUnit case and rename update_rule test
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirFilonov committed Sep 8, 2024
1 parent f6328d7 commit 1822937
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions keep/api/routes/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class RuleCreateDto(BaseModel):
sqlQuery: dict
celQuery: str
timeframeInSeconds: int
timeunit: str
timeUnit: str
groupingCriteria: list = []
groupDescription: str = None
requireApprove: bool = False
Expand Down Expand Up @@ -66,7 +66,7 @@ async def create_rule(
rule_name = rule_create_request.ruleName
cel_query = rule_create_request.celQuery
timeframe = rule_create_request.timeframeInSeconds
timeunit = rule_create_request.timeunit
timeunit = rule_create_request.timeUnit
grouping_criteria = rule_create_request.groupingCriteria
group_description = rule_create_request.groupDescription
require_approve = rule_create_request.requireApprove
Expand Down
10 changes: 5 additions & 5 deletions tests/test_rules_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"created_by": "[email protected]",
}

INVALIDA_DATA_STEPS = [{
INVALID_DATA_STEPS = [{
"update": {"sqlQuery": {"sql": "", "params": []}},
"error": "SQL is required",
}, {
Expand Down Expand Up @@ -74,7 +74,7 @@ def test_create_rule_api(client, db_session, test_app):
"sqlQuery": {"sql": "SELECT * FROM alert where severity = %s", "params": ["critical"]},
"celQuery": "severity = 'critical'",
"timeframeInSeconds": 300,
"timeunit": "seconds",
"timeUnit": "seconds",
"requireApprove": False,
}

Expand Down Expand Up @@ -104,7 +104,7 @@ def test_create_rule_api(client, db_session, test_app):
assert data["detail"][0]["loc"] == ["body", "ruleName"]
assert data["detail"][0]["msg"] == "field required"

for invalid_data_step in INVALIDA_DATA_STEPS:
for invalid_data_step in INVALID_DATA_STEPS:
current_step = "Invalid data step: {}".format(invalid_data_step["error"])
invalid_data_response_2 = client.post(
"/rules",
Expand Down Expand Up @@ -145,7 +145,7 @@ def test_delete_rule_api(client, db_session, test_app):


@pytest.mark.parametrize("test_app", ["NO_AUTH"], indirect=True)
def test_create_rule_api(client, db_session, test_app):
def test_update_rule_api(client, db_session, test_app):

rule = create_rule_db(**TEST_RULE_DATA)

Expand All @@ -169,7 +169,7 @@ def test_create_rule_api(client, db_session, test_app):
assert data["name"] == "test rule"
assert data["definition_cel"] == "severity = 'critical'"

for invalid_data_step in INVALIDA_DATA_STEPS:
for invalid_data_step in INVALID_DATA_STEPS:
current_step = "Invalid data step: {}".format(invalid_data_step["error"])
invalid_data_response_2 = client.put(
"/rules/{}".format(rule.id),
Expand Down

0 comments on commit 1822937

Please sign in to comment.