function MonitoringServicesTest::testSensorInfo in Monitoring 7
Test sensor info API calls.
File
- test/
tests/ monitoring.services.test, line 41 - Contains \MonitoringServicesTest.
Class
- MonitoringServicesTest
- Tests for cron sensor.
Code
function testSensorInfo() {
$this
->drupalLogin($this->servicesAccount);
$response_data = $this
->doRequest('sensor-info');
$this
->assertResponse(200);
foreach (monitoring_sensor_info() as $sensor_name => $sensor_info) {
$this
->assertEqual($response_data[$sensor_name]['sensor'], $sensor_info
->getName());
$this
->assertEqual($response_data[$sensor_name]['label'], $sensor_info
->getLabel());
$this
->assertEqual($response_data[$sensor_name]['category'], $sensor_info
->getCategory());
$this
->assertEqual($response_data[$sensor_name]['description'], $sensor_info
->getDescription());
$this
->assertEqual($response_data[$sensor_name]['numeric'], $sensor_info
->isNumeric());
$this
->assertEqual($response_data[$sensor_name]['value_label'], $sensor_info
->getValueLabel());
$this
->assertEqual($response_data[$sensor_name]['caching_time'], $sensor_info
->getCachingTime());
$this
->assertEqual($response_data[$sensor_name]['time_interval'], $sensor_info
->getTimeIntervalValue());
$this
->assertEqual($response_data[$sensor_name]['enabled'], $sensor_info
->isEnabled());
$this
->assertEqual($response_data[$sensor_name]['uri'], url('monitoring/v1/sensor-info/' . $sensor_info
->getName(), array(
'absolute' => TRUE,
)));
if ($sensor_info
->isDefiningThresholds()) {
$this
->assertEqual($response_data[$sensor_name]['thresholds'], $sensor_info
->getSetting('thresholds'));
}
}
$sensor_name = 'sensor_that_does_not_exist';
$this
->doRequest('sensor-info/' . $sensor_name);
$this
->assertResponse(404);
$sensor_name = 'dblog_event_severity_error';
$response_data = $this
->doRequest('sensor-info/' . $sensor_name);
$this
->assertResponse(200);
$sensor_info = monitoring_sensor_manager()
->getSensorInfoByName($sensor_name);
$this
->assertEqual($response_data['sensor'], $sensor_info
->getName());
$this
->assertEqual($response_data['label'], $sensor_info
->getLabel());
$this
->assertEqual($response_data['category'], $sensor_info
->getCategory());
$this
->assertEqual($response_data['description'], $sensor_info
->getDescription());
$this
->assertEqual($response_data['numeric'], $sensor_info
->isNumeric());
$this
->assertEqual($response_data['value_label'], $sensor_info
->getValueLabel());
$this
->assertEqual($response_data['caching_time'], $sensor_info
->getCachingTime());
$this
->assertEqual($response_data['time_interval'], $sensor_info
->getTimeIntervalValue());
$this
->assertEqual($response_data['enabled'], $sensor_info
->isEnabled());
$this
->assertEqual($response_data['uri'], url('monitoring/v1/sensor-info/' . $sensor_info
->getName(), array(
'absolute' => TRUE,
)));
if ($sensor_info
->isDefiningThresholds()) {
$this
->assertEqual($response_data['thresholds'], $sensor_info
->getSetting('thresholds'));
}
}