Skip to content

Commit b46864d

Browse files
authored
fix: Solve v2 events not scoping created events (#180)
* fix: Solve v2 events not scoping created events * fix(ci): Sleep after creating the event
1 parent 5baddf9 commit b46864d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

sdcclient/monitor/_events_v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def post_event(self, name, description=None, severity=None, event_filter=None, t
123123
'name': name,
124124
'description': description,
125125
'severity': severity,
126-
'filter': event_filter,
126+
'scope': event_filter,
127127
'tags': tags
128128
}
129129
edata = {

specs/monitor/events_v2_spec.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import time
33
from datetime import datetime, timedelta
4+
from time import sleep
45

56
from expects import expect, have_key, contain, have_keys, be_empty, equal, be_false, be_above_or_equal, have_len
67
from mamba import it, before, context, description
@@ -19,6 +20,18 @@
1920
description="This event was created in a CI pipeline for the Python SDK library")
2021
expect(call).to(be_successful_api_call)
2122

23+
with it("is able to create a custom event with a scope"):
24+
call = self.client.post_event(name=self.event_name,
25+
description="This event was created in a CI pipeline for the Python SDK library",
26+
event_filter="host.hostName='ci'")
27+
expect(call).to(be_successful_api_call)
28+
sleep(2) # sleep to guarantee the event is created
29+
30+
ok, res = self.client.get_events()
31+
expect((ok, res)).to(be_successful_api_call)
32+
expect(res).to(have_key("events"))
33+
expect(res["events"]).to(contain(have_key("scope", equal("host.hostName = 'ci'"))))
34+
2235
with it("is able to list the events happened without any filter"):
2336
time.sleep(3) # Wait for the event to appear in the feed
2437
ok, res = self.client.get_events()

0 commit comments

Comments
 (0)