Skip to content

Commit

Permalink
Added test for aggregation source creation via event
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Pinto <christian.pinto@ibm.com>
  • Loading branch information
christian-pinto committed Sep 22, 2023
1 parent 7e02192 commit bd17874
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,25 @@ def test_create_chassis(self):
response = self.client.post(chassis_url, json=test_templates.test_chassis)
status_code = response.status_code
self.assertEqual(status_code, 200)

def test_aggregation_source_creation (self):
events_url = f"/EventListener"
response = self.client.post(events_url, json=test_templates.test_aggregation_source_event)
status_code = response.status_code
self.assertEqual(status_code, 200)

manager_name = test_templates.test_aggregation_source_event["Events"][0]["OriginOfCondition"]["@odata.id"].split('/')[-1]
aggr_source_url = f"{REST_BASE}/AggregationService/AggregationSources/{manager_name}"
response = self.client.get(aggr_source_url)
status_code = response.status_code
self.assertEqual(status_code, 200)
response_payload = response.get_json()

#Check Aggregtion SOurce got created with proper Id
self.assertEqual(response_payload["Id"], manager_name)
#Check the Hostoname:port was properly parsed
hostname = f"{test_templates.test_aggregation_source_event['Events'][0]['MessageArgs'][0]}:{test_templates.test_aggregation_source_event['Events'][0]['MessageArgs'][1]}"
self.assertEqual(response_payload["HostName"], hostname)

if __name__ == '__main__':
unittest.main()
Expand Down
20 changes: 20 additions & 0 deletions tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,24 @@
],
}

}

test_aggregation_source_event = {
"@odata.type": "#Event.v1_7_0.Event",
"Id": "1",
"Name": "Manager Created",
"Context": "",
"Events": [
{
"EventType": "Other",
"EventId": "4594",
"Severity": "Ok",
"Message": "New Manager Available at FQDN http://foo.bar.org and Port 1234 ",
"MessageId": "Manager.1.0.AggregationSourceDiscovered",
"MessageArgs": [ "http://foo.bar.org", "1234" ],
"OriginOfCondition": {
"@odata.id": "/redfish/v1/Managers/Manager1"
}
}
]
}

0 comments on commit bd17874

Please sign in to comment.