<s> import unittest <EOL> from nose . tools import * <EOL> from amonone . alerts . alerter import ServerAlerter <EOL> from amonone . web . apps . core . models import server_model <EOL> from amonone . web . apps . alerts . models import alerts_model <EOL> test_system_data = { u'<STR_LIT>' : { u'<STR_LIT>' : <NUM_LIT> , u'<STR_LIT>' : <NUM_LIT> , u'<STR_LIT>' : <NUM_LIT> } } <EOL> rule = { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } <EOL> class ServerAlerterTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . alerter = ServerAlerter ( ) <EOL> def test_check ( self ) : <EOL> alerts_model . collection . remove ( ) <EOL> server_model . collection . remove ( ) <EOL> server_model . collection . insert ( { "<STR_LIT>" : "<STR_LIT:test>" , "<STR_LIT:key>" : "<STR_LIT>" } ) <EOL> server = server_model . collection . find_one ( ) <EOL> server_id = str ( server [ '<STR_LIT>' ] ) <EOL> rule [ '<STR_LIT>' ] = server_id <EOL> alerts_model . save ( rule ) <EOL> check = self . alerter . check ( data = test_system_data , server = server , alert_type = '<STR_LIT>' ) <EOL> eq_ ( check [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , str ( rule [ '<STR_LIT>' ] ) ) </s>
