File tree 2 files changed +42
-2
lines changed
2 files changed +42
-2
lines changed Original file line number Diff line number Diff line change @@ -678,7 +678,10 @@ def _is_translation(r):
678
678
679
679
def _find_actual_release_from_pseudo_release (pseudo_rel : Dict ) \
680
680
-> Optional [Dict ]:
681
- relations = pseudo_rel ['release' ]["release-relation-list" ]
681
+ try :
682
+ relations = pseudo_rel ['release' ]["release-relation-list" ]
683
+ except KeyError :
684
+ return None
682
685
683
686
# currently we only support trans(liter)ation's
684
687
translations = [r for r in relations if _is_translation (r )]
Original file line number Diff line number Diff line change @@ -724,7 +724,7 @@ def test_follow_pseudo_releases(self):
724
724
album = mb .album_for_id ('d2a6f856-b553-40a0-ac54-a321e8e2da02' )
725
725
self .assertEqual (album .country , 'COUNTRY' )
726
726
727
- def test_pseudo_releases_without_links (self ):
727
+ def test_pseudo_releases_with_empty_links (self ):
728
728
side_effect = [{
729
729
'release' : {
730
730
'title' : 'pseudo' ,
@@ -762,6 +762,43 @@ def test_pseudo_releases_without_links(self):
762
762
album = mb .album_for_id ('d2a6f856-b553-40a0-ac54-a321e8e2da02' )
763
763
self .assertEqual (album .country , None )
764
764
765
+ def test_pseudo_releases_without_links (self ):
766
+ side_effect = [{
767
+ 'release' : {
768
+ 'title' : 'pseudo' ,
769
+ 'id' : 'd2a6f856-b553-40a0-ac54-a321e8e2da02' ,
770
+ 'status' : 'Pseudo-Release' ,
771
+ 'medium-list' : [{
772
+ 'track-list' : [{
773
+ 'id' : 'baz' ,
774
+ 'recording' : {
775
+ 'title' : 'translated title' ,
776
+ 'id' : 'bar' ,
777
+ 'length' : 42 ,
778
+ },
779
+ 'position' : 9 ,
780
+ 'number' : 'A1' ,
781
+ }],
782
+ 'position' : 5 ,
783
+ }],
784
+ 'artist-credit' : [{
785
+ 'artist' : {
786
+ 'name' : 'some-artist' ,
787
+ 'id' : 'some-id' ,
788
+ },
789
+ }],
790
+ 'release-group' : {
791
+ 'id' : 'another-id' ,
792
+ },
793
+ }
794
+ },
795
+ ]
796
+
797
+ with mock .patch ('musicbrainzngs.get_release_by_id' ) as gp :
798
+ gp .side_effect = side_effect
799
+ album = mb .album_for_id ('d2a6f856-b553-40a0-ac54-a321e8e2da02' )
800
+ self .assertEqual (album .country , None )
801
+
765
802
def test_pseudo_releases_with_unsupported_links (self ):
766
803
side_effect = [
767
804
{
You can’t perform that action at this time.
0 commit comments