Ejemplo n.º 1
0
    def test_same_statsd_client_for_same_prefix(self) -> None:
        with patch.object(current_app, 'config') as mock_config, \
                patch.object(StatsClient, '__init__', return_value=None) as mock_statsd_init:
            mock_config.return_value.single.return_value = True

            statsd_client1 = _get_statsd_client(prefix='test_same')
            self.assertIsNotNone(statsd_client1)
            statsd_client2 = _get_statsd_client(prefix='test_same')
            self.assertIsNotNone(statsd_client2)
            self.assertEqual(statsd_client1, statsd_client2)

            self.assertEqual(mock_statsd_init.call_count, 1)
Ejemplo n.º 2
0
    def test_get_statsd_client(self) -> None:
        with patch.object(current_app, 'config') as mock_config, \
                patch.object(StatsClient, '__init__', return_value=None):
            mock_config.return_value.single.return_value = True

            statsd_client1 = _get_statsd_client(prefix='test')
            self.assertIsNotNone(statsd_client1)
Ejemplo n.º 3
0
 def test_no_statsd_client(self) -> None:
     with patch.object(StatsClient, '__init__'):
         statsd_client = _get_statsd_client(prefix='foo')
         self.assertIsNone(statsd_client)