Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Add id for Annotation update #49

Merged
merged 2 commits into from
Oct 20, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion grafana_api/api/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def add_annotation_graphite(

def update_annotation(
self,
annotations_id,
time_from=None,
time_to=None,
is_region=True,
Expand All @@ -134,7 +135,7 @@ def update_annotation(
:param text:
:return:
"""
annotations_path = "/annotations"
annotations_path = "/annotations/{}".format(annotations_id)
payload = {
"time": time_from,
"timeEnd": time_to,
Expand Down
8 changes: 5 additions & 3 deletions test/api/test_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import requests_mock

from grafana_api.grafana_api import (GrafanaBadInputError, GrafanaClientError,
GrafanaServerError,
GrafanaUnauthorizedError)
from grafana_api.grafana_face import GrafanaFace
from grafana_api.grafana_api import GrafanaServerError,GrafanaClientError,GrafanaUnauthorizedError,GrafanaBadInputError


class AnnotationsTestCase(unittest.TestCase):
Expand Down Expand Up @@ -139,10 +141,10 @@ def test_add_annotation(self, m):
@requests_mock.Mocker()
def test_update_annotation(self, m):
m.put(
"http://localhost/api/annotations",
"http://localhost/api/annotations/79",
json={"endId": 80, "id": 79, "message": "Annotation updated"},
)
annotation = self.cli.annotations.update_annotation(time_from=1563183710618, time_to=1563185212275
annotation = self.cli.annotations.update_annotation(annotations_id=79, time_from=1563183710618, time_to=1563185212275
, is_region=True, tags="tags-test", text="Test")
self.assertEqual(annotation["endId"], 80)
self.assertEqual(annotation["id"], 79)
Expand Down