2020
2121- `has_program` checks the presence of a command on the system.
2222
23- - The `generate_album_info` and `generate_track_info` functions return
24- fixtures to be used when mocking the autotagger.
25-
2623- The `ImportSessionFixture` allows one to run importer code while
2724 controlling the interactions through code.
2825
@@ -249,16 +246,15 @@ def create_item(self, **values):
249246
250247 The item is attached to the database from `self.lib`.
251248 """
252- item_count = self ._get_item_count ()
253249 values_ = {
254250 "title" : "t\u00ef tle {0}" ,
255251 "artist" : "the \u00e4 rtist" ,
256252 "album" : "the \u00e4 lbum" ,
257- "track" : item_count ,
253+ "track" : 1 ,
258254 "format" : "MP3" ,
259255 }
260256 values_ .update (values )
261- values_ ["title" ] = values_ ["title" ].format (item_count )
257+ values_ ["title" ] = values_ ["title" ].format (1 )
262258 values_ ["db" ] = self .lib
263259 item = Item (** values_ )
264260 if "path" not in values :
@@ -375,12 +371,6 @@ def create_mediafile_fixture(self, ext="mp3", images=[]):
375371
376372 return path
377373
378- def _get_item_count (self ):
379- if not hasattr (self , "__item_count" ):
380- count = 0
381- self .__item_count = count + 1
382- return count
383-
384374 # Running beets commands
385375
386376 def run_command (self , * args , ** kwargs ):
@@ -723,10 +713,6 @@ def choose_match(self, task):
723713
724714 default_resolution = "REMOVE"
725715
726- def add_resolution (self , resolution ):
727- assert isinstance (resolution , self .Resolution )
728- self ._resolutions .append (resolution )
729-
730716 def resolve_duplicate (self , task , found_duplicates ):
731717 try :
732718 res = self ._resolutions .pop (0 )
@@ -779,12 +765,10 @@ def _add_choice_input(self):
779765 self .io .addinput ("T" )
780766 elif choice == importer .action .SKIP :
781767 self .io .addinput ("S" )
782- elif isinstance ( choice , int ) :
768+ else :
783769 self .io .addinput ("M" )
784770 self .io .addinput (str (choice ))
785771 self ._add_choice_input ()
786- else :
787- raise Exception ("Unknown choice %s" % choice )
788772
789773
790774class TerminalImportMixin (ImportHelper ):
@@ -803,82 +787,6 @@ def _get_import_session(self, import_dir: bytes) -> importer.ImportSession:
803787 )
804788
805789
806- def generate_album_info (album_id , track_values ):
807- """Return `AlbumInfo` populated with mock data.
808-
809- Sets the album info's `album_id` field is set to the corresponding
810- argument. For each pair (`id`, `values`) in `track_values` the `TrackInfo`
811- from `generate_track_info` is added to the album info's `tracks` field.
812- Most other fields of the album and track info are set to "album
813- info" and "track info", respectively.
814- """
815- tracks = [generate_track_info (id , values ) for id , values in track_values ]
816- album = AlbumInfo (
817- album_id = "album info" ,
818- album = "album info" ,
819- artist = "album info" ,
820- artist_id = "album info" ,
821- tracks = tracks ,
822- )
823- for field in ALBUM_INFO_FIELDS :
824- setattr (album , field , "album info" )
825-
826- return album
827-
828-
829- ALBUM_INFO_FIELDS = [
830- "album" ,
831- "album_id" ,
832- "artist" ,
833- "artist_id" ,
834- "asin" ,
835- "albumtype" ,
836- "va" ,
837- "label" ,
838- "barcode" ,
839- "artist_sort" ,
840- "releasegroup_id" ,
841- "catalognum" ,
842- "language" ,
843- "country" ,
844- "albumstatus" ,
845- "media" ,
846- "albumdisambig" ,
847- "releasegroupdisambig" ,
848- "artist_credit" ,
849- "data_source" ,
850- "data_url" ,
851- ]
852-
853-
854- def generate_track_info (track_id = "track info" , values = {}):
855- """Return `TrackInfo` populated with mock data.
856-
857- The `track_id` field is set to the corresponding argument. All other
858- string fields are set to "track info".
859- """
860- track = TrackInfo (
861- title = "track info" ,
862- track_id = track_id ,
863- )
864- for field in TRACK_INFO_FIELDS :
865- setattr (track , field , "track info" )
866- for field , value in values .items ():
867- setattr (track , field , value )
868- return track
869-
870-
871- TRACK_INFO_FIELDS = [
872- "artist" ,
873- "artist_id" ,
874- "artist_sort" ,
875- "disctitle" ,
876- "artist_credit" ,
877- "data_source" ,
878- "data_url" ,
879- ]
880-
881-
882790class AutotagStub :
883791 """Stub out MusicBrainz album and track matcher and control what the
884792 autotagger returns.
0 commit comments