def testFileTrack(self): Factories.clear() file1 = FileFactory.get(self.path, self.artist, self.title) file2 = FileFactory.get(self.path2, self.artist, self.title) found = 0 for f in file1.track.files(): found += 1 self.assertEqual(found, 2)
def testFileClear(self): Factories.clear() file = FileFactory.get(self.path, self.artist, self.title) file.test = self.file_test self.assertEqual(file.test, self.file_test) Factories.clear() file = FileFactory.get(self.path, self.artist, self.title) self.assertEqual(file.test, None)
def testFileRef(self): Factories.clear() file = FileFactory.get(self.path, self.artist, self.title) file.test = self.file_test file.track.test = self.track_test file.track.artist.test = self.artist_test fileRef = FileFactory.get(self.path, self.artist, self.title) self.assertEqual(fileRef.path, self.path) self.assertEqual(fileRef.track.artist.name, self.artist) self.assertEqual(fileRef.track.title, self.title) self.assertEqual(fileRef.test, self.file_test) self.assertEqual(fileRef.track.test, self.track_test) self.assertEqual(fileRef.track.artist.test, self.artist_test)
def testFilePickle(self): Factories.clear() file = FileFactory.get(self.path, self.artist, self.title) file.test = self.file_test file.track.test = self.track_test file.track.artist.test = self.artist_test state = pickle.dumps(Factories.getstate()) Factories.clear() file = FileFactory.get(self.path, self.artist, self.title) Factories.clear() pickle.loads(state) file = FileFactory.get(self.path, self.artist, self.title) self.assertEqual(file.path, self.path) self.assertEqual(file.track.artist.name, self.artist) self.assertEqual(file.track.title, self.title) self.assertEqual(file.test, self.file_test) self.assertEqual(file.track.test, self.track_test) self.assertEqual(file.track.artist.test, self.artist_test)
def dump_stats(self): self._logger.info(u"%d artists, %d tracks %d files" % ( ArtistFactory.len(), TrackFactory.len(), FileFactory.len()))
def get_file(self, path): f = FileFactory.by_path(path) if not f: self._logger.error(u"file not recognized %s" % path) return None return f
def _add_file(self, path, artist_name, track_title): self.acquire() f = FileFactory.get(path, artist_name, track_title) f.activate() self.release()
def _deactivate(self, dummy=None): """ set all artists, albums, tracks and files to be not active """ self.acquire() FileFactory.deactivate() self.release()