def test_update_library(self, track_for_mbid, album_for_mbid): album_for_mbid.return_value = \ generate_album_info('album id', ['track id']) track_for_mbid.return_value = \ generate_track_info(u'singleton track id', {'title': u'singleton info'}) album_item = Item( album=u'old title', mb_albumid=u'album id', mb_trackid=u'track id', path='' ) album = self.lib.add_album([album_item]) item = Item( title=u'old title', mb_trackid=u'singleton track id', path='', ) self.lib.add(item) self.run_command('mbsync') item.load() self.assertEqual(item.title, u'singleton info') album_item.load() self.assertEqual(album_item.title, u'track info') album.load() self.assertEqual(album.album, u'album info')
def test_store_data(self, echonest_track, echonest_profile, item_write): profile = Mock( artist_name='artist', title='title', id='echonestid', audio_summary={ 'duration': 10, 'energy': 0.5, 'liveness': 0.5, 'loudness': 0.5, 'speechiness': 0.5, 'danceability': 0.5, 'tempo': 120, 'key': 2, 'mode': 0 }, ) echonest_profile.return_value = [profile] echonest_track.return_value = Mock(song_id='echonestid') item = Item( mb_trackid='01234', artist='artist', title='title', length=10, ) item.add(self.lib) self.assertNotIn('danceability', item) self.assertNotIn('initialkey', item) self.run_command('echonest') item.load() self.assertEqual(item['danceability'], '0.5') self.assertEqual(item['initial_key'], 'C#m')
def test_store_data(self, echonest_track, echonest_profile, item_write): profile = Mock( artist_name='artist', title='title', id='echonestid', audio_summary={ 'duration': 10, 'energy': 0.5, 'liveness': 0.5, 'loudness': 0.5, 'speechiness': 0.5, 'danceability': 0.5, 'tempo': 120, 'key': 2, 'mode': 0 }, ) echonest_profile.return_value = [profile] echonest_track.return_value = Mock(song_id='echonestid') item = Item( mb_trackid='01234', artist='artist', title='title', length=10, ) item.add(self.lib) self.assertNotIn('danceability', item) self.assertNotIn('initialkey', item) self.run_command('echonest') item.load() self.assertEqual(item['danceability'], '0.5') self.assertEqual(item['initial_key'], 'C#m')
def test_update_library(self, track_for_mbid, album_for_mbid): album_for_mbid.return_value = \ generate_album_info('album id', ['track id']) track_for_mbid.return_value = \ generate_track_info('singleton track id', {'title': 'singleton info'}) album_item = Item(album='old title', mb_albumid='album id', mb_trackid='track id', path='') album = self.lib.add_album([album_item]) item = Item( title='old title', mb_trackid='singleton track id', path='', ) self.lib.add(item) self.run_command('mbsync') item.load() self.assertEqual(item.title, 'singleton info') album_item.load() self.assertEqual(album_item.title, 'track info') album.load() self.assertEqual(album.album, 'album info')
def test_normal_case(self): item = Item(path='/file', mb_workid='1', parentwork_workid_current='1') item.add(self.lib) self.run_command('parentwork') item.load() self.assertEqual(item['mb_parentworkid'], '3')
def test_do_not_overwrite(self): item = Item(path='/file', initial_key='F') item.add(self.lib) self.command_output.return_value = 'dbm' self.run_command('keyfinder') item.load() self.assertEqual(item['initial_key'], 'F')
def test_do_not_overwrite(self): item = Item(path='/file', initial_key='F') item.add(self.lib) self.command_output.return_value = 'dbm' self.run_command('keyfinder') item.load() self.assertEqual(item['initial_key'], 'F')
def test_do_not_overwrite(self): item = Item(path="/file", initial_key="F") item.add(self.lib) self.command_output.return_value = "dbm" self.run_command("keyfinder") item.load() self.assertEqual(item["initial_key"], "F")
def test_no_key(self, command_output): item = Item(path='/file') item.add(self.lib) command_output.return_value = util.CommandOutput(b"", b"") self.run_command('keyfinder') item.load() self.assertEqual(item['initial_key'], None)
def test_do_not_overwrite(self, command_output): item = Item(path='/file', initial_key='F') item.add(self.lib) command_output.return_value = util.CommandOutput(b"dbm", b"") self.run_command('keyfinder') item.load() self.assertEqual(item['initial_key'], 'F')
def test_add_key(self): item = Item(path='/file') item.add(self.lib) self.command_output.return_value = 'dbm' self.run_command('keyfinder') item.load() self.assertEqual(item['initial_key'], 'C#m') self.command_output.assert_called_with(['KeyFinder', '-f', item.path])
def test_normal_case(self): item = Item(path='/file', mb_workid=u'e27bda6e-531e-36d3-9cd7-b8ebc18e8c53') item.add(self.lib) self.run_command('parentwork') item.load() self.assertEqual(item['mb_parentworkid'], u'32c8943f-1b27-3a23-8660-4567f4847c94')
def test_add_key(self): item = Item(path="/file") item.add(self.lib) self.command_output.return_value = "dbm" self.run_command("keyfinder") item.load() self.assertEqual(item["initial_key"], "C#m") self.command_output.assert_called_with(["KeyFinder", "-f", item.path])
def test_add_key(self, command_output): item = Item(path='/file') item.add(self.lib) command_output.return_value = util.CommandOutput(b"dbm", b"") self.run_command('keyfinder') item.load() self.assertEqual(item['initial_key'], 'C#m') command_output.assert_called_with( ['KeyFinder', '-f', util.syspath(item.path)])
def test_force_overwrite(self): self.config['keyfinder']['overwrite'] = True item = Item(path='/file', initial_key='F') item.add(self.lib) self.command_output.return_value = 'C#m' self.run_command('keyfinder') item.load() self.assertEqual(item['initial_key'], 'C#m')
def test_add_key(self): item = Item(path='/file') item.add(self.lib) self.command_output.return_value = 'dbm' self.run_command('keyfinder') item.load() self.assertEqual(item['initial_key'], 'C#m') self.command_output.assert_called_with( ['KeyFinder', '-f', item.path])
def test_force_overwrite(self): self.config['keyfinder']['overwrite'] = True item = Item(path='/file', initial_key='F') item.add(self.lib) self.command_output.return_value = 'C#m' self.run_command('keyfinder') item.load() self.assertEqual(item['initial_key'], 'C#m')
def test_force_overwrite(self): self.config["keyfinder"]["overwrite"] = True item = Item(path="/file", initial_key="F") item.add(self.lib) self.command_output.return_value = "C#m" self.run_command("keyfinder") item.load() self.assertEqual(item["initial_key"], "C#m")
def test_force(self): self.config['parentwork']['force'] = True item = Item(path='/file', mb_workid=u'e27bda6e-531e-36d3-9cd7-b8ebc18e8c53', mb_parentworkid=u'XXX') item.add(self.lib) self.run_command('parentwork') item.load() self.assertEqual(item['mb_parentworkid'], u'32c8943f-1b27-3a23-8660-4567f4847c94')
def test_no_force(self): self.config['parentwork']['force'] = True item = Item(path='/file', mb_workid=u'e27bda6e-531e-36d3-9cd7-\ b8ebc18e8c53', mb_parentworkid=u'XXX') item.add(self.lib) self.run_command('parentwork') item.load() self.assertEqual(item['mb_parentworkid'], u'XXX')
def test_no_force(self): self.config['parentwork']['force'] = False item = Item(path='/file', mb_workid='1', mb_parentworkid=u'XXX', parentwork_workid_current='1', parentwork='parentwork') item.add(self.lib) self.run_command('parentwork') item.load() self.assertEqual(item['mb_parentworkid'], u'XXX')
def test_no_force_real(self): self.config['parentwork']['force'] = False item = Item(path='/file', mb_workid='e27bda6e-531e-36d3-9cd7-\ b8ebc18e8c53', mb_parentworkid='XXX', parentwork_workid_current='e27bda6e-531e-36d3-9cd7-\ b8ebc18e8c53', parentwork='whatever') item.add(self.lib) self.run_command('parentwork') item.load() self.assertEqual(item['mb_parentworkid'], 'XXX')
def test_update_library(self, track_for_mbid, album_for_mbid): album_for_mbid.return_value = generate_album_info("album id", ["track id"]) track_for_mbid.return_value = generate_track_info(u"singleton track id", {"title": u"singleton info"}) album_item = Item(album=u"old title", mb_albumid=u"album id", mb_trackid=u"track id", path="") album = self.lib.add_album([album_item]) item = Item(title=u"old title", mb_trackid=u"singleton track id", path="") self.lib.add(item) self.run_command("mbsync") item.load() self.assertEqual(item.title, u"singleton info") album_item.load() self.assertEqual(album_item.title, u"track info") album.load() self.assertEqual(album.album, u"album info")
def test_update_library(self, track_for_id, album_for_id): album_for_id.return_value = \ generate_album_info( 'album id', [('track id', {'release_track_id': u'release track id'})] ) track_for_id.return_value = \ generate_track_info(u'singleton track id', {'title': u'singleton info'}) album_item = Item( album=u'old title', mb_albumid=u'81ae60d4-5b75-38df-903a-db2cfa51c2c6', mb_trackid=u'old track id', mb_releasetrackid=u'release track id', path='' ) album = self.lib.add_album([album_item]) item = Item( title=u'old title', mb_trackid=u'b8c2cf90-83f9-3b5f-8ccd-31fb866fcf37', path='', ) self.lib.add(item) with capture_log() as logs: self.run_command('mbsync') self.assertIn('Sending event: albuminfo_received', logs) self.assertIn('Sending event: trackinfo_received', logs) item.load() self.assertEqual(item.title, u'singleton info') album_item.load() self.assertEqual(album_item.title, u'track info') self.assertEqual(album_item.mb_trackid, u'track id') album.load() self.assertEqual(album.album, u'album info')
def test_update_library(self, track_for_id, album_for_id): album_for_id.return_value = \ generate_album_info( 'album id', [('track id', {'release_track_id': u'release track id'})] ) track_for_id.return_value = \ generate_track_info(u'singleton track id', {'title': u'singleton info'}) album_item = Item(album=u'old title', mb_albumid=u'81ae60d4-5b75-38df-903a-db2cfa51c2c6', mb_trackid=u'old track id', mb_releasetrackid=u'release track id', path='') album = self.lib.add_album([album_item]) item = Item( title=u'old title', mb_trackid=u'b8c2cf90-83f9-3b5f-8ccd-31fb866fcf37', path='', ) self.lib.add(item) with capture_log() as logs: self.run_command('mbsync') self.assertIn('Sending event: albuminfo_received', logs) self.assertIn('Sending event: trackinfo_received', logs) item.load() self.assertEqual(item.title, u'singleton info') album_item.load() self.assertEqual(album_item.title, u'track info') self.assertEqual(album_item.mb_trackid, u'track id') album.load() self.assertEqual(album.album, u'album info')