<s> from spec . unit . fixtures import Internal , patch_gpod_module <EOL> gpod = patch_gpod_module ( ) <EOL> from ipodio . track import Track <EOL> from ipodio . database import Database <EOL> from expects import expect <EOL> from mamba import describe , context , before <EOL> with describe ( Database ) as _ : <EOL> with context ( '<STR_LIT>' ) : <EOL> def should_have_an_internal_database ( ) : <EOL> expect ( _ . fabricated . internal ) . to . be . an ( _ . internal_class ) <EOL> with context ( '<STR_LIT>' ) : <EOL> def should_have_an_empty_index ( ) : <EOL> expect ( _ . database . index ) . to . be . empty <EOL> def should_be_marked_as_not_updated ( ) : <EOL> expect ( _ . database . updated ) . to . be . false <EOL> with context ( '<STR_LIT>' ) : <EOL> def should_return_an_empty_collection ( ) : <EOL> expect ( _ . database . find_by_hash ( _ . hash ) ) . to . be . empty <EOL> with context ( '<STR_LIT>' ) : <EOL> def should_return_None ( ) : <EOL> expect ( _ . database . get_by_hash ( _ . hash ) ) . to . be . none <EOL> with context ( '<STR_LIT>' ) : <EOL> def should_return_a_list_with_tracks ( ) : <EOL> expect ( _ . database . tracks ) . not_to . be . empty <EOL> with context ( '<STR_LIT>' ) : <EOL> def should_populate_index ( ) : <EOL> expect ( _ . database . index ) . not_to . be . empty <EOL> with context ( '<STR_LIT>' ) : <EOL> def should_return_a_collection ( ) : <EOL> expect ( _ . database . find_by_hash ( _ . hash ) ) . not_to . be . empty <EOL> with context ( '<STR_LIT>' ) : <EOL> def should_return_a_Track ( ) : <EOL> expect ( _ . database . get_by_hash ( _ . hash ) ) . to . be . a ( Track ) <EOL> def should_return_a_track_with_the_given_hash ( ) : <EOL> expect ( _ . database . get_by_hash ( _ . hash ) ) . to . have . property ( '<STR_LIT>' , _ . hash ) <EOL> with context ( '<STR_LIT>' ) : <EOL> def should_be_a_collection ( ) : <EOL> expect ( _ . database . tracks ) . not_to . be . empty <EOL> @ before . all <EOL> def fixture ( ) : <EOL> _ . database . update_index ( ) <EOL> with context ( '<STR_LIT>' ) : <EOL> def should_be_a_list ( ) : <EOL> expect ( _ . database . playlists ) . to . be . a ( list ) <EOL> @ before . all <EOL> def fixtures ( ) : <EOL> _ . internal_class = Internal <EOL> _ . hash = '<STR_LIT>' <EOL> _ . internal_track = Internal ( { '<STR_LIT>' : { '<STR_LIT>' : _ . hash } } ) <EOL> _ . database = Database ( Internal ( [ _ . internal_track ] ) ) <EOL> _ . fabricated = Database . create ( '<STR_LIT>' , internal_class = _ . internal_class ) </s>
