<s> '''<STR_LIT>''' <EOL> import unittest <EOL> from unittest import TestCase <EOL> from mock import MagicMock <EOL> import sys <EOL> from os import path <EOL> sys . path . append ( path . dirname ( path . dirname ( path . abspath ( __file__ ) ) ) ) <EOL> from kafka_monitor import KafkaMonitor <EOL> from plugins . action_handler import ActionHandler <EOL> import settings <EOL> import redis <EOL> import json <EOL> class CustomHandler ( ActionHandler ) : <EOL> def handle ( self , dict ) : <EOL> key = "<STR_LIT>" <EOL> self . redis_conn . set ( key , dict [ '<STR_LIT>' ] ) <EOL> class TestKafkaMonitor ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . kafka_monitor = KafkaMonitor ( "<STR_LIT>" ) <EOL> new_settings = self . kafka_monitor . wrapper . load ( "<STR_LIT>" ) <EOL> new_settings [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> new_settings [ '<STR_LIT>' ] = False <EOL> new_settings [ '<STR_LIT>' ] = False <EOL> new_settings [ '<STR_LIT>' ] = { <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : <NUM_LIT:100> , <EOL> } <EOL> self . kafka_monitor . wrapper . load = MagicMock ( return_value = new_settings ) <EOL> self . kafka_monitor . setup ( ) <EOL> self . kafka_monitor . _setup_kafka ( ) <EOL> self . kafka_monitor . _load_plugins ( ) <EOL> self . kafka_monitor . _setup_stats ( ) <EOL> self . kafka_monitor . logger = MagicMock ( ) <EOL> self . redis_conn = redis . Redis ( <EOL> host = self . kafka_monitor . settings [ '<STR_LIT>' ] , <EOL> port = self . kafka_monitor . settings [ '<STR_LIT>' ] ) <EOL> def test_feed ( self ) : <EOL> json_req = "<STR_LIT>" "<STR_LIT>" <EOL> parsed = json . loads ( json_req ) <EOL> self . kafka_monitor . feed ( parsed ) <EOL> def test_run ( self ) : <EOL> self . kafka_monitor . _process_messages ( ) <EOL> self . assertTrue ( self . redis_conn . exists ( "<STR_LIT>" ) ) <EOL> value = self . redis_conn . get ( "<STR_LIT>" ) <EOL> self . assertEqual ( value , "<STR_LIT>" ) <EOL> def tearDown ( self ) : <EOL> self . redis_conn . delete ( "<STR_LIT>" ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
