File: test_utils.py

package info (click to toggle)
python-django-etcd-settings 0.1.13%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 328 kB
  • ctags: 276
  • sloc: python: 925; makefile: 210
file content (40 lines) | stat: -rw-r--r-- 1,011 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import logging
import unittest

from etcd_settings import utils


class TestLoggingFilter(unittest.TestCase):

    def setUp(self):
        self.logger_filter = utils.IgnoreMaxEtcdRetries()

    def test_log_record_without_args(self):
        self.assertTrue(
            self.logger_filter.filter(
                logging.LogRecord(
                    'etcd.client',
                    logging.ERROR,
                    '/',
                    0,
                    'Read timed out',
                    tuple(),
                    None
                )
            )
        )

    def test_log_record_match(self):
        self.assertFalse(
            self.logger_filter.filter(
                logging.LogRecord(
                    'etcd.client',
                    logging.ERROR,
                    '/',
                    0,
                    'Error %s exception %s',
                    ('Read timed out', 'MaxRetryError'),
                    None
                )
            )
        )