20
20
21
21
- `has_program` checks the presence of a command on the system.
22
22
23
- - The `generate_album_info` and `generate_track_info` functions return
24
- fixtures to be used when mocking the autotagger.
25
-
26
23
- The `ImportSessionFixture` allows one to run importer code while
27
24
controlling the interactions through code.
28
25
@@ -249,16 +246,15 @@ def create_item(self, **values):
249
246
250
247
The item is attached to the database from `self.lib`.
251
248
"""
252
- item_count = self ._get_item_count ()
253
249
values_ = {
254
250
"title" : "t\u00ef tle {0}" ,
255
251
"artist" : "the \u00e4 rtist" ,
256
252
"album" : "the \u00e4 lbum" ,
257
- "track" : item_count ,
253
+ "track" : 1 ,
258
254
"format" : "MP3" ,
259
255
}
260
256
values_ .update (values )
261
- values_ ["title" ] = values_ ["title" ].format (item_count )
257
+ values_ ["title" ] = values_ ["title" ].format (1 )
262
258
values_ ["db" ] = self .lib
263
259
item = Item (** values_ )
264
260
if "path" not in values :
@@ -375,12 +371,6 @@ def create_mediafile_fixture(self, ext="mp3", images=[]):
375
371
376
372
return path
377
373
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
-
384
374
# Running beets commands
385
375
386
376
def run_command (self , * args , ** kwargs ):
@@ -723,10 +713,6 @@ def choose_match(self, task):
723
713
724
714
default_resolution = "REMOVE"
725
715
726
- def add_resolution (self , resolution ):
727
- assert isinstance (resolution , self .Resolution )
728
- self ._resolutions .append (resolution )
729
-
730
716
def resolve_duplicate (self , task , found_duplicates ):
731
717
try :
732
718
res = self ._resolutions .pop (0 )
@@ -779,12 +765,10 @@ def _add_choice_input(self):
779
765
self .io .addinput ("T" )
780
766
elif choice == importer .action .SKIP :
781
767
self .io .addinput ("S" )
782
- elif isinstance ( choice , int ) :
768
+ else :
783
769
self .io .addinput ("M" )
784
770
self .io .addinput (str (choice ))
785
771
self ._add_choice_input ()
786
- else :
787
- raise Exception ("Unknown choice %s" % choice )
788
772
789
773
790
774
class TerminalImportMixin (ImportHelper ):
@@ -803,82 +787,6 @@ def _get_import_session(self, import_dir: bytes) -> importer.ImportSession:
803
787
)
804
788
805
789
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
-
882
790
class AutotagStub :
883
791
"""Stub out MusicBrainz album and track matcher and control what the
884
792
autotagger returns.
0 commit comments