Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for options on delete #513

Merged
merged 8 commits into from
Jan 28, 2020
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions tests/integration/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,32 @@ def test_monitor_can_delete(self):
"deleted_monitor_id": monitor["id"]
}

def test_monitor_can_delete_with_force(self):
# Create a monitor.
query = "avg(last_1h):sum:system.net.bytes_rcvd{host:host0} > 100"
options = {
"silenced": {"*": int(time.time()) + 60 * 60},
"notify_no_data": False,
}
monitor = dog.Monitor.create(type="metric alert", query=query, options=options)
monitor_ids = [monitor["id"]]

# Create a monitor-based SLO.
name = "test SLO {}".format(time.time())
thresholds = [{"timeframe": "7d", "target": 90}]
slo = dog.ServiceLevelObjective.create(
type="monitor",
monitor_ids=monitor_ids,
dabcoder marked this conversation as resolved.
Show resolved Hide resolved
thresholds=thresholds,
name=name,
)["data"][0]

# Check if you can delete the monitor with force option
options = {"force": True}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. We'll also have to add a note about this options argument in the docs since it currently mentions it dors not take any JSON args: https://docs.datadoghq.com/api/?lang=python#delete-a-monitor once it's live.

assert dog.Monitor.delete(monitor["id"], options=options) == {
"deleted_monitor_id": monitor["id"]
}

def test_service_level_objective_crud(self):
numerator = "sum:my.custom.metric{type:good}.as_count()"
denominator = "sum:my.custom.metric{*}.as_count()"
Expand Down