<s> from __future__ import division , absolute_import , print_function <EOL> from mock import patch <EOL> from beets import library <EOL> from beetsplug . ipfs import IPFSPlugin <EOL> from test import _common <EOL> from test . _common import unittest <EOL> from test . helper import TestHelper <EOL> import os <EOL> class IPFSPluginTest ( unittest . TestCase , TestHelper ) : <EOL> def setUp ( self ) : <EOL> self . setup_beets ( ) <EOL> self . load_plugins ( '<STR_LIT>' ) <EOL> self . patcher = patch ( '<STR_LIT>' ) <EOL> self . command_output = self . patcher . start ( ) <EOL> self . lib = library . Library ( "<STR_LIT>" ) <EOL> def tearDown ( self ) : <EOL> self . unload_plugins ( ) <EOL> self . teardown_beets ( ) <EOL> self . patcher . stop ( ) <EOL> def test_stored_hashes ( self ) : <EOL> test_album = self . mk_test_album ( ) <EOL> ipfs = IPFSPlugin ( ) <EOL> added_albums = ipfs . ipfs_added_albums ( self . lib , self . lib . path ) <EOL> added_album = added_albums . get_album ( <NUM_LIT:1> ) <EOL> self . assertEqual ( added_album . ipfs , test_album . ipfs ) <EOL> found = False <EOL> want_item = test_album . items ( ) [ <NUM_LIT:2> ] <EOL> for check_item in added_album . items ( ) : <EOL> try : <EOL> if check_item . ipfs : <EOL> want_path = '<STR_LIT>' . format ( test_album . ipfs , <EOL> os . path . basename ( <EOL> want_item . path ) ) <EOL> self . assertEqual ( check_item . path , want_path ) <EOL> self . assertEqual ( check_item . ipfs , want_item . ipfs ) <EOL> self . assertEqual ( check_item . title , want_item . title ) <EOL> found = True <EOL> except AttributeError : <EOL> pass <EOL> self . assertTrue ( found ) <EOL> def mk_test_album ( self ) : <EOL> items = [ _common . item ( ) for _ in range ( <NUM_LIT:3> ) ] <EOL> items [ <NUM_LIT:0> ] . title = '<STR_LIT>' <EOL> items [ <NUM_LIT:0> ] . artist = '<STR_LIT>' <EOL> items [ <NUM_LIT:0> ] . album = '<STR_LIT>' <EOL> items [ <NUM_LIT:0> ] . year = <NUM_LIT> <EOL> items [ <NUM_LIT:0> ] . comp = True <EOL> items [ <NUM_LIT:1> ] . title = '<STR_LIT>' <EOL> items [ <NUM_LIT:1> ] . artist = '<STR_LIT>' <EOL> items [ <NUM_LIT:1> ] . album = '<STR_LIT>' <EOL> items [ <NUM_LIT:1> ] . year = <NUM_LIT> <EOL> items [ <NUM_LIT:1> ] . comp = True <EOL> items [ <NUM_LIT:2> ] . title = '<STR_LIT>' <EOL> items [ <NUM_LIT:2> ] . artist = '<STR_LIT>' <EOL> items [ <NUM_LIT:2> ] . album = '<STR_LIT:foo>' <EOL> items [ <NUM_LIT:2> ] . year = <NUM_LIT> <EOL> items [ <NUM_LIT:2> ] . comp = False <EOL> items [ <NUM_LIT:2> ] . ipfs = '<STR_LIT>' <EOL> for item in items : <EOL> self . lib . add ( item ) <EOL> album = self . lib . add_album ( items ) <EOL> album . ipfs = "<STR_LIT>" <EOL> album . store ( ) <EOL> return album <EOL> def suite ( ) : <EOL> return unittest . TestLoader ( ) . loadTestsFromName ( __name__ ) <EOL> if __name__ == b'<STR_LIT:__main__>' : <EOL> unittest . main ( defaultTest = '<STR_LIT>' ) </s>
