X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Ftest%2FOpenStack%2Funit%2Ftest_alarm_req.py;h=f767c4741530c747a8e8e8ddf71a908bb497cc16;hb=6a25034efeefc28121fa2cd16d655e5620bd8c47;hp=0d2016bac0f206844216fe1a5a1d35cd99123eed;hpb=ffe5a8e4e35d3fc7860eb9231618dc0e84e448b7;p=osm%2FMON.git diff --git a/osm_mon/test/OpenStack/unit/test_alarm_req.py b/osm_mon/test/OpenStack/unit/test_alarm_req.py index 0d2016b..f767c47 100644 --- a/osm_mon/test/OpenStack/unit/test_alarm_req.py +++ b/osm_mon/test/OpenStack/unit/test_alarm_req.py @@ -73,8 +73,8 @@ class TestAlarmKeys(unittest.TestCase): self.alarming.alarming(message, 'test_id') - get_token.assert_called_with('test_id') - get_endpoint.assert_any_call('alarming', 'test_id') + get_token.assert_called_with('test_id', verify_ssl=True) + get_endpoint.assert_any_call('alarming', 'test_id', verify_ssl=True) @mock.patch.object(Common, 'get_endpoint', mock.Mock()) @mock.patch.object(Common, 'get_auth_token', mock.Mock()) @@ -95,7 +95,7 @@ class TestAlarmKeys(unittest.TestCase): # Call the alarming functionality and check delete request self.alarming.alarming(message, 'test_id') - del_alarm.assert_called_with(mock.ANY, mock.ANY, 'my_alarm_id') + del_alarm.assert_called_with(mock.ANY, mock.ANY, 'my_alarm_id', True) @mock.patch.object(Common, 'get_endpoint', mock.Mock()) @mock.patch.object(Common, 'get_auth_token', mock.Mock()) @@ -114,7 +114,7 @@ class TestAlarmKeys(unittest.TestCase): # Call the alarming functionality and check list functionality self.alarming.alarming(message, 'test_id') - list_alarm.assert_called_with(mock.ANY, mock.ANY, {'correlation_id': 1}) + list_alarm.assert_called_with(mock.ANY, mock.ANY, {'correlation_id': 1}, True) @mock.patch.object(Common, 'get_auth_token', mock.Mock()) @mock.patch.object(Common, 'get_endpoint', mock.Mock()) @@ -132,14 +132,15 @@ class TestAlarmKeys(unittest.TestCase): # Call alarming functionality and check acknowledge functionality self.alarming.alarming(message, 'test_id') - ack_alarm.assert_called_with(mock.ANY, mock.ANY, 'my_alarm_id') + ack_alarm.assert_called_with(mock.ANY, mock.ANY, 'my_alarm_id', True) @mock.patch.object(Common, 'get_auth_token', mock.Mock()) @mock.patch.object(Common, 'get_endpoint', mock.Mock()) @mock.patch.object(DatabaseManager, 'save_alarm', mock.Mock()) + @mock.patch.object(Common, "perform_request") @mock.patch.object(AuthManager, 'get_credentials') @mock.patch.object(alarm_req.Alarming, 'configure_alarm') - def test_config_alarm_key(self, config_alarm, get_creds): + def test_config_alarm_key(self, config_alarm, get_creds, perf_req): """Test the functionality for a create alarm request.""" # Mock a message with config alarm key and value message = Message() @@ -148,15 +149,18 @@ class TestAlarmKeys(unittest.TestCase): 'operation': 'GT', 'metric_name': 'cpu_utilization', 'vdu_name': 'vdu', 'vnf_member_index': '1', - 'ns_id': '1'}}) - + 'ns_id': '1', + 'resource_uuid': '123'}}) + mock_perf_req_return_value = {"metrics": {"cpu_util": 123}} + perf_req.return_value = type('obj', (object,), {'text': json.dumps(mock_perf_req_return_value, sort_keys=True)}) get_creds.return_value = mock_creds # Call alarming functionality and check config alarm call - config_alarm.return_value = 'my_alarm_id', True + config_alarm.return_value = 'my_alarm_id' self.alarming.alarming(message, 'test_id') - config_alarm.assert_called_with(mock.ANY, mock.ANY, mock.ANY, {'correlation_id': 1, 'threshold_value': 50, - 'operation': 'GT', - 'metric_name': 'cpu_utilization', - 'vdu_name': 'vdu', - 'vnf_member_index': '1', 'ns_id': '1'}, {}) + config_alarm.assert_called_with(mock.ANY, mock.ANY, {'correlation_id': 1, 'threshold_value': 50, + 'operation': 'GT', + 'metric_name': 'cpu_utilization', + 'vdu_name': 'vdu', + 'vnf_member_index': '1', 'ns_id': '1', + 'resource_uuid': '123'}, {}, True)