|
13 | 13 | token=os.getenv("SDC_SECURE_TOKEN"))
|
14 | 14 | with context("when we try to retrieve policy events from the last 7 days"):
|
15 | 15 | with it("returns the list of all events happened"):
|
16 |
| - day_in_seconds = 7 * 24 * 60 * 60 |
| 16 | + week_in_seconds = 7 * 24 * 60 * 60 |
17 | 17 |
|
18 |
| - ok, res = self.client.get_policy_events_duration(day_in_seconds) |
| 18 | + ok, res = self.client.get_policy_events_duration(week_in_seconds) |
19 | 19 |
|
20 | 20 | expect((ok, res)).to(be_successful_api_call)
|
21 | 21 | expect(res).to(have_keys("ctx", "data"))
|
|
34 | 34 | contain(have_keys("id", "timestamp", "customerId", "source", "name", "description", "cursor")))
|
35 | 35 |
|
36 | 36 | with it("returns the list of all events from the last 7 days that match a filter"):
|
37 |
| - day_in_seconds = 7 * 24 * 60 * 60 |
| 37 | + week_in_seconds = 7 * 24 * 60 * 60 |
38 | 38 |
|
39 |
| - ok, res = self.client.get_policy_events_duration(day_in_seconds, filter='severity in ("4","5")') |
| 39 | + ok, res = self.client.get_policy_events_duration(week_in_seconds, filter='severity in ("4","5")') |
40 | 40 |
|
41 | 41 | expect((ok, res)).to(be_successful_api_call)
|
42 | 42 | expect(res).to(have_keys("ctx", "data"))
|
43 | 43 | expect(res["data"]).to(contain(have_key("severity", be_within(3, 6))))
|
44 | 44 |
|
45 | 45 | with it("returns an empty list if the filter does not match"):
|
46 |
| - day_in_seconds = 7 * 24 * 60 * 60 |
| 46 | + week_in_seconds = 7 * 24 * 60 * 60 |
47 | 47 |
|
48 |
| - ok, res = self.client.get_policy_events_duration(day_in_seconds, filter='severity in ("-1")') |
| 48 | + ok, res = self.client.get_policy_events_duration(week_in_seconds, filter='severity in ("-1")') |
49 | 49 |
|
50 | 50 | expect((ok, res)).to(be_successful_api_call)
|
51 | 51 | expect(res).to(have_keys("ctx", "data"))
|
|
54 | 54 | with _context("and from the first event we retrieve the rest of events"):
|
55 | 55 | # Deactivated tests. There seems to be a bug in the API -- need confirmation
|
56 | 56 | with it("returns the list of all events except the first"):
|
57 |
| - day_in_seconds = 7 * 24 * 60 * 60 |
58 |
| - _, res = self.client.get_policy_events_duration(day_in_seconds) |
| 57 | + week_in_seconds = 7 * 24 * 60 * 60 |
| 58 | + _, res = self.client.get_policy_events_duration(week_in_seconds) |
59 | 59 | ctx = {"cursor": res["data"][0]["cursor"]}
|
60 | 60 | qty_before = len(res["data"])
|
61 | 61 |
|
|
76 | 76 | }
|
77 | 77 | call = self.client.get_more_policy_events(wrong_context)
|
78 | 78 | expect(call).to_not(be_successful_api_call)
|
| 79 | + |
| 80 | + with context("while retrieving a single event"): |
| 81 | + with it("retrieves the event correctly"): |
| 82 | + week_in_seconds = 7 * 24 * 60 * 60 |
| 83 | + ok, res = self.client.get_policy_events_duration(week_in_seconds) |
| 84 | + |
| 85 | + expect((ok, res)).to(be_successful_api_call) |
| 86 | + |
| 87 | + event_id = res["data"][0]["id"] |
| 88 | + ok, res = self.client.get_policy_event(event_id) |
| 89 | + |
| 90 | + expect((ok, res)).to(be_successful_api_call) |
| 91 | + expect(res).to(have_keys("name", "timestamp", "customerId", "originator", "machineId", id=event_id)) |
0 commit comments