<s> from nose . plugins . attrib import attr <EOL> from checks import AgentCheck <EOL> from tests . checks . common import AgentCheckTest <EOL> @ attr ( requires = '<STR_LIT>' ) <EOL> class ZooKeeperTestCase ( AgentCheckTest ) : <EOL> CHECK_NAME = '<STR_LIT>' <EOL> CONFIG = { <EOL> '<STR_LIT:host>' : "<STR_LIT:127.0.0.1>" , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : "<STR_LIT>" , <EOL> '<STR_LIT>' : [ "<STR_LIT>" ] <EOL> } <EOL> WRONG_EXPECTED_MODE = { <EOL> '<STR_LIT:host>' : "<STR_LIT:127.0.0.1>" , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : "<STR_LIT>" , <EOL> '<STR_LIT>' : [ ] <EOL> } <EOL> CONNECTION_FAILURE_CONFIG = { <EOL> '<STR_LIT:host>' : "<STR_LIT:127.0.0.1>" , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : "<STR_LIT>" , <EOL> '<STR_LIT>' : [ ] <EOL> } <EOL> METRICS = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> def test_check ( self ) : <EOL> """<STR_LIT>""" <EOL> config = { <EOL> '<STR_LIT>' : [ self . CONFIG ] <EOL> } <EOL> self . run_check ( config ) <EOL> for mname in self . METRICS : <EOL> self . assertMetric ( mname , tags = [ "<STR_LIT>" , "<STR_LIT>" ] , count = <NUM_LIT:1> ) <EOL> self . assertServiceCheck ( "<STR_LIT>" , status = AgentCheck . OK ) <EOL> self . assertServiceCheck ( "<STR_LIT>" , status = AgentCheck . OK ) <EOL> self . coverage_report ( ) <EOL> def test_wrong_expected_mode ( self ) : <EOL> """<STR_LIT>""" <EOL> config = { <EOL> '<STR_LIT>' : [ self . WRONG_EXPECTED_MODE ] <EOL> } <EOL> self . run_check ( config ) <EOL> self . assertServiceCheck ( "<STR_LIT>" , status = AgentCheck . CRITICAL ) <EOL> def test_error_state ( self ) : <EOL> """<STR_LIT>""" <EOL> config = { <EOL> '<STR_LIT>' : [ self . CONNECTION_FAILURE_CONFIG ] <EOL> } <EOL> self . assertRaises ( <EOL> Exception , <EOL> lambda : self . run_check ( config ) <EOL> ) <EOL> self . assertServiceCheck ( "<STR_LIT>" , status = AgentCheck . CRITICAL ) </s>
