コード例 #1
0
ファイル: tests.py プロジェクト: mvpoland/django-statsd
    def test_patched_executemany_calls_timer(self):
        for operation, query in self.example_queries.items():
            with mock.patch.object(statsd, 'timer') as timer:
                client = mock.Mock(executable_name='client_executable_name')
                db = mock.Mock(executable_name='name', alias='alias', client=client)
                instance = mock.Mock(db=db)

                patched_executemany(lambda *args, **kwargs: None, instance, query)

                self.assertEqual(timer.call_count, 1)
                self.assertEqual(timer.call_args[0][0], 'db.client_executable_name.alias.executemany.%s' % operation)
コード例 #2
0
    def test_patched_executemany_calls_timer(self):
        for operation, query in list(self.example_queries.items()):
            with mock.patch.object(statsd, 'timer') as timer:
                client = mock.Mock(executable_name='client_executable_name')
                db = mock.Mock(executable_name='name', alias='alias', client=client)
                instance = mock.Mock(db=db)

                patched_executemany(lambda *args, **kwargs: None, instance, query)

                self.assertEqual(timer.call_count, 1)
                self.assertEqual(timer.call_args[0][0], 'db.client_executable_name.alias.executemany.%s' % operation)
コード例 #3
0
    def test_patched_executemany_calls_timer(self):
        for operation, query in list(self.example_queries.items()):
            with patch('django_statsd.patches.db.statsd') as statsd_mock:
                client = Mock(executable_name='client_executable_name')
                db = Mock(executable_name='name', alias='alias', client=client)
                instance = Mock(db=db)

                patched_executemany(lambda *args, **kwargs: None, instance,
                                    query)

                self.assertEqual(statsd_mock.timer.call_count, 1)
                self.assertEqual(
                    statsd_mock.timer.call_args[0][0],
                    'db.client_executable_name.alias.executemany.%s' %
                    operation)
コード例 #4
0
ファイル: tests.py プロジェクト: Gointer/django-statsd
 def test_patched_executemany_calls_timer(self):
     with mock.patch.object(statsd, 'timer') as timer:
         db = mock.Mock(executable_name='name', alias='alias')
         instance = mock.Mock(db=db)
         patched_executemany(lambda *args, **kwargs: None, instance)
         self.assertEqual(timer.call_count, 1)