@@ -0,0 +1,2042 @@
+# (C) Copyright 2019 Fujitsu Limited%0A#%0A# Licensed under the Apache License, Version 2.0 (the %22License%22);%0A# you may not use this file except in compliance with the License.%0A# You may obtain a copy of the License at%0A#%0A# http://www.apache.org/licenses/LICENSE-2.0%0A#%0A# Unless required by applicable law or agreed to in writing, software%0A# distributed under the License is distributed on an %22AS IS%22 BASIS,%0A# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or%0A# implied.%0A# See the License for the specific language governing permissions and%0A# limitations under the License.%0A%0Afrom mock import Mock%0Afrom mock import patch%0Afrom six import string_types%0A%0Afrom oslotest import base%0Afrom oslo_config import cfg%0A%0Afrom monasca_persister.repositories.influxdb.metrics_repository import MetricInfluxdbRepository%0A%0A%0Aclass TestMetricInfluxdbRepository(base.BaseTestCase):%0A%0A    def setUp(self):%0A        super(TestMetricInfluxdbRepository, self).setUp()%0A%0A    def tearDown(self):%0A        super(TestMetricInfluxdbRepository, self).tearDown()%0A%0A    def test_process_message(self):%0A        metric = self._get_metric()%0A        with patch.object(cfg, 'CONF', return_value=None):%0A            metric_repo = MetricInfluxdbRepository()%0A            self.assertIsInstance(metric_repo.process_message(metric), string_types)%0A%0A    def _get_metric(self):%0A        metric = '''%0A            %7B%0A              %22metric%22:%0A              %7B%0A                %22timestamp%22:1554725987408.1049804688,%0A                %22name%22:%22process.cpu_perc%22,%0A                %22dimensions%22:%0A                %7B%0A                  %22process_name%22:%22persister%22,%0A                  %22hostname%22:%22devstack%22,%0A                  %22service%22:%22persister%22%0A                %7D,%0A                %22value%22:7.5,%0A                %22value_meta%22:null%7D,%0A                %22meta%22:%0A                %7B%0A                  %22region%22:%22RegionOne%22,%0A                  %22tenantId%22:%22df4c002353de4399b92fa79d8374819b%22%0A                %7D,%0A                %22creation_time%22:1554725988%0A            %7D%0A        '''%0A        return Mock(message=Mock(value=metric))%0A

Add tests for influxdb/metrics_repository.py