<s> """<STR_LIT>""" <EOL> from collections import namedtuple <EOL> import logging <EOL> import unittest <EOL> from homeassistant . components import logger <EOL> RECORD = namedtuple ( '<STR_LIT>' , ( '<STR_LIT:name>' , '<STR_LIT>' ) ) <EOL> class TestUpdater ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> """<STR_LIT>""" <EOL> self . log_config = { '<STR_LIT>' : <EOL> { '<STR_LIT:default>' : '<STR_LIT>' , '<STR_LIT>' : { '<STR_LIT:test>' : '<STR_LIT:info>' } } } <EOL> def tearDown ( self ) : <EOL> """<STR_LIT>""" <EOL> del logging . root . handlers [ - <NUM_LIT:1> ] <EOL> def test_logger_setup ( self ) : <EOL> """<STR_LIT>""" <EOL> logger . setup ( None , self . log_config ) <EOL> self . assertTrue ( len ( logging . root . handlers ) > <NUM_LIT:0> ) <EOL> handler = logging . root . handlers [ - <NUM_LIT:1> ] <EOL> self . assertEqual ( len ( handler . filters ) , <NUM_LIT:1> ) <EOL> log_filter = handler . filters [ <NUM_LIT:0> ] . logfilter <EOL> self . assertEqual ( log_filter [ '<STR_LIT:default>' ] , logging . WARNING ) <EOL> self . assertEqual ( log_filter [ '<STR_LIT>' ] [ '<STR_LIT:test>' ] , logging . INFO ) <EOL> def test_logger_test_filters ( self ) : <EOL> """<STR_LIT>""" <EOL> logger . setup ( None , self . log_config ) <EOL> log_filter = logging . root . handlers [ - <NUM_LIT:1> ] . filters [ <NUM_LIT:0> ] <EOL> record = RECORD ( '<STR_LIT>' , logging . DEBUG ) <EOL> self . assertFalse ( log_filter . filter ( record ) ) <EOL> record = RECORD ( '<STR_LIT>' , logging . WARNING ) <EOL> self . assertTrue ( log_filter . filter ( record ) ) <EOL> record = RECORD ( '<STR_LIT:test>' , logging . DEBUG ) <EOL> self . assertFalse ( log_filter . filter ( record ) ) <EOL> record = RECORD ( '<STR_LIT:test>' , logging . INFO ) <EOL> self . assertTrue ( log_filter . filter ( record ) ) </s>
