

@run_only_if_pymongo_is_available
@patch('pymongo.Connection')
@patch.object(Collector, 'publish')
def test_should_publish_nested_keys_for_db_stats(self, publish_mock, connector_mock):
    data = {
        'db_keys': {
            'db_nested_key': 1,
        },
        'dbkey': 2,
        'dbstring': 'str',
    }
    self._annotate_connection(connector_mock, data)
    self.collector.collect()
    self.connection['db1'].command.assert_called_with('dbStats')
    metrics = {
        'localhost_27017.db_keys.db_nested_key': 1,
        'localhost_27057.db_keys.db_nested_key': 1,
        'localhost_27017.dbkey': 2,
        'localhost_27057.dbkey': 2,
    }
    self.setDocExample(collector=self.collector.__class__.__name__, metrics=metrics, defaultpath=self.collector.config['path'])
    self.assertPublishedMany(publish_mock, metrics)

dataset/ETHPy150Open BrightcoveOS/Diamond/src/collectors/mongodb/test/testmongodb.py TestMongoMultiHostDBCollector.test_should_publish_nested_keys_for_db_stats/original