<s> import fixtures <EOL> import json <EOL> from elastic_recheck import loader <EOL> import elastic_recheck . tests <EOL> def load_empty ( ) : <EOL> with open ( "<STR_LIT>" ) as f : <EOL> return json . load ( f ) <EOL> def load_by_bug ( bug ) : <EOL> with open ( "<STR_LIT>" % bug ) as f : <EOL> return json . load ( f ) <EOL> class FakeES ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , url ) : <EOL> self . _yaml = loader . load ( '<STR_LIT>' ) <EOL> self . _queries = { } <EOL> for item in self . _yaml : <EOL> self . _queries [ item [ '<STR_LIT>' ] . rstrip ( ) ] = item [ '<STR_LIT>' ] <EOL> def search ( self , query , ** kwargs ) : <EOL> qstring = query [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> if qstring in self . _queries : <EOL> return load_by_bug ( self . _queries [ qstring ] ) <EOL> return load_empty ( ) <EOL> class UnitTestCase ( elastic_recheck . tests . TestCase ) : <EOL> def setUp ( self ) : <EOL> super ( UnitTestCase , self ) . setUp ( ) <EOL> self . useFixture ( fixtures . MonkeyPatch ( '<STR_LIT>' , <EOL> FakeES ) ) </s>
