def metric_streaming(self): """ Gets the MetricStreaming API client. Returns: MetricStreaming: """ if not self.__metric_streaming: self.__metric_streaming = MetricStreaming(self.__connection) return self.__metric_streaming
class MetricStreamingTest(TestCase): def setUp(self): self.host = '127.0.0.1' self.connection = connection(self.host) self._metrics = MetricStreaming(self.connection) @mock.patch.object(ResourceClient, 'get') def test_get_capability_called_once(self, mock_get): self._metrics.get_capability() mock_get.assert_called_once_with("/rest/metrics/capability") @mock.patch.object(ResourceClient, 'get') def test_get_configuration_called_once(self, mock_get): self._metrics.get_configuration() mock_get.assert_called_once_with("/rest/metrics/configuration") @mock.patch.object(ResourceClient, 'update') def test_update_should_use_given_values(self, mock_update): configuration = { "sourceTypeList": [{ "sourceType": "/rest/power-devices", "sampleIntervalInSeconds": "300", "frequencyOfRelayInSeconds": "3600" }] } configuration_rest_call = configuration.copy() mock_update.return_value = configuration self._metrics.update_configuration(configuration) mock_update.assert_called_once_with(configuration_rest_call, uri="/rest/metrics/configuration")
class MetricStreamingTest(TestCase): def setUp(self): self.host = '127.0.0.1' self.connection = connection(self.host) self._metrics = MetricStreaming(self.connection) @mock.patch.object(ResourceClient, 'get') def test_get_capability_called_once(self, mock_get): self._metrics.get_capability() mock_get.assert_called_once_with("/rest/metrics/capability") @mock.patch.object(ResourceClient, 'get') def test_get_configuration_called_once(self, mock_get): self._metrics.get_configuration() mock_get.assert_called_once_with("/rest/metrics/configuration") @mock.patch.object(ResourceClient, 'update') def test_update_should_use_given_values(self, mock_update): configuration = { "sourceTypeList": [ { "sourceType": "/rest/power-devices", "sampleIntervalInSeconds": "300", "frequencyOfRelayInSeconds": "3600" } ] } configuration_rest_call = configuration.copy() mock_update.return_value = configuration self._metrics.update_configuration(configuration) mock_update.assert_called_once_with(configuration_rest_call, uri="/rest/metrics/configuration")
def setUp(self): self.host = '127.0.0.1' self.connection = connection(self.host) self._metrics = MetricStreaming(self.connection)
def setUp(self): self.host = '127.0.0.1' self.connection = connection(self.host) self._metrics = MetricStreaming(self.connection)
def metric_streaming(self): if not self.__metric_streaming: self.__metric_streaming = MetricStreaming(self.__connection) return self.__metric_streaming