Skip to content

Commit

Permalink
mock api album, nil in track equals, fix urgent bug in search
Browse files Browse the repository at this point in the history
  • Loading branch information
tanja04 committed Jun 23, 2024
1 parent fba487f commit 6c15097
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 132 deletions.
240 changes: 121 additions & 119 deletions src/SpotifyConnect/SPOCApiAlbum.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ Class {

{
#category : #parameters,
#'squeak_changestamp' : 'RK 6/13/2024 23:16'
#'squeak_changestamp' : 'TL 6/23/2024 15:54'
}
SPOCApiAlbum >> endpoint [

^ 'v1/albums/'
]

{
#category : #parameters,
#'squeak_changestamp' : 'RK 5/16/2024 18:51'
#'squeak_changestamp' : 'TL 6/23/2024 15:54'
}
SPOCApiAlbum >> endpointMethod [

^ 'GET'
]

Expand All @@ -32,127 +34,127 @@ SPOCApiAlbum >> executeRequest: request withParams: aParameterDictionary [

{
#category : #response,
#'squeak_changestamp' : 'RK 6/16/2024 13:15'
#'squeak_changestamp' : 'TL 6/23/2024 15:43'
}
SPOCApiAlbum >> executeTest [

^ '{
"href": "https://api.spotify.com/v1/albums/6DEjYFkNZh67HP7R9PSZvv/tracks?offset=0&limit=3&locale=de,en-US;q%3D0.7,en;q%3D0.3",
"items": [
{
"artists": [
{
"external_urls": {
"spotify": "https://open.spotify.com/artist/06HL4z0CvFAxyc27GXpf02"
},
"href": "https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02",
"id": "06HL4z0CvFAxyc27GXpf02",
"name": "Taylor Swift",
"type": "artist",
"uri": "spotify:artist:06HL4z0CvFAxyc27GXpf02"
}
],
"disc_number": 1,
"duration_ms": 208186,
"explicit": false,
"external_urls": {
"spotify": "https://open.spotify.com/track/2yLa0QULdQr0qAIvVwN6B5"
},
"href": "https://api.spotify.com/v1/tracks/2yLa0QULdQr0qAIvVwN6B5",
"id": "2yLa0QULdQr0qAIvVwN6B5",
"is_local": false,
"is_playable": true,
"name": "...Ready For It?",
"preview_url": "https://p.scdn.co/mp3-preview/f133e47ce7d5f768be3387758d71bc1a8a5726f5?cid=cfe923b2d660439caf2b557b21f31221",
"track_number": 1,
"type": "track",
"uri": "spotify:track:2yLa0QULdQr0qAIvVwN6B5"
},
{
"artists": [
{
"external_urls": {
"spotify": "https://open.spotify.com/artist/06HL4z0CvFAxyc27GXpf02"
},
"href": "https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02",
"id": "06HL4z0CvFAxyc27GXpf02",
"name": "Taylor Swift",
"type": "artist",
"uri": "spotify:artist:06HL4z0CvFAxyc27GXpf02"
},
{
"external_urls": {
"spotify": "https://open.spotify.com/artist/6eUKZXaKkcviH0Ku9w2n3V"
},
"href": "https://api.spotify.com/v1/artists/6eUKZXaKkcviH0Ku9w2n3V",
"id": "6eUKZXaKkcviH0Ku9w2n3V",
"name": "Ed Sheeran",
"type": "artist",
"uri": "spotify:artist:6eUKZXaKkcviH0Ku9w2n3V"
},
{
"external_urls": {
"spotify": "https://open.spotify.com/artist/1RyvyyTE3xzB2ZywiAwp0i"
},
"href": "https://api.spotify.com/v1/artists/1RyvyyTE3xzB2ZywiAwp0i",
"id": "1RyvyyTE3xzB2ZywiAwp0i",
"name": "Future",
"type": "artist",
"uri": "spotify:artist:1RyvyyTE3xzB2ZywiAwp0i"
}
],
"disc_number": 1,
"duration_ms": 244826,
"explicit": false,
"external_urls": {
"spotify": "https://open.spotify.com/track/2x0WlnmfG39ZuDmstl9xfX"
},
"href": "https://api.spotify.com/v1/tracks/2x0WlnmfG39ZuDmstl9xfX",
"id": "2x0WlnmfG39ZuDmstl9xfX",
"is_local": false,
"is_playable": true,
"name": "End Game",
"preview_url": "https://p.scdn.co/mp3-preview/908f388e5550f9d6d940ef721eb6d302770f0117?cid=cfe923b2d660439caf2b557b21f31221",
"track_number": 2,
"type": "track",
"uri": "spotify:track:2x0WlnmfG39ZuDmstl9xfX"
},
{
"artists": [
{
"external_urls": {
"spotify": "https://open.spotify.com/artist/06HL4z0CvFAxyc27GXpf02"
},
"href": "https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02",
"id": "06HL4z0CvFAxyc27GXpf02",
"name": "Taylor Swift",
"type": "artist",
"uri": "spotify:artist:06HL4z0CvFAxyc27GXpf02"
}
],
"disc_number": 1,
"duration_ms": 238253,
"explicit": false,
"external_urls": {
"spotify": "https://open.spotify.com/track/4svZDCRz4cJoneBpjpx8DJ"
},
"href": "https://api.spotify.com/v1/tracks/4svZDCRz4cJoneBpjpx8DJ",
"id": "4svZDCRz4cJoneBpjpx8DJ",
"is_local": false,
"is_playable": true,
"name": "I Did Something Bad",
"preview_url": "https://p.scdn.co/mp3-preview/ef43901885fc52988f3192152a8019fc7a34f0d5?cid=cfe923b2d660439caf2b557b21f31221",
"track_number": 3,
"type": "track",
"uri": "spotify:track:4svZDCRz4cJoneBpjpx8DJ"
}
],
"limit": 3,
"next": "https://api.spotify.com/v1/albums/6DEjYFkNZh67HP7R9PSZvv/tracks?offset=3&limit=3&locale=de,en-US;q%3D0.7,en;q%3D0.3",
"offset": 0,
"previous": null,
"total": 15
}' readStream
"href": "https://api.spotify.com/v1/albums/6DEjYFkNZh67HP7R9PSZvv/tracks?offset=0&limit=3&locale=de,en-US;q%3D0.7,en;q%3D0.3",
"items": [
{
"artists": [
{
"external_urls": {
"spotify": "https://open.spotify.com/artist/06HL4z0CvFAxyc27GXpf02"
},
"href": "https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02",
"id": "06HL4z0CvFAxyc27GXpf02",
"name": "Taylor Swift",
"type": "artist",
"uri": "spotify:artist:06HL4z0CvFAxyc27GXpf02"
}
],
"disc_number": 1,
"duration_ms": 208186,
"explicit": false,
"external_urls": {
"spotify": "https://open.spotify.com/track/2yLa0QULdQr0qAIvVwN6B5"
},
"href": "https://api.spotify.com/v1/tracks/2yLa0QULdQr0qAIvVwN6B5",
"id": "2yLa0QULdQr0qAIvVwN6B5",
"is_local": false,
"is_playable": true,
"name": "...Ready For It?",
"preview_url": "https://p.scdn.co/mp3-preview/f133e47ce7d5f768be3387758d71bc1a8a5726f5?cid=cfe923b2d660439caf2b557b21f31221",
"track_number": 1,
"type": "track",
"uri": "spotify:track:2yLa0QULdQr0qAIvVwN6B5"
},
{
"artists": [
{
"external_urls": {
"spotify": "https://open.spotify.com/artist/06HL4z0CvFAxyc27GXpf02"
},
"href": "https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02",
"id": "06HL4z0CvFAxyc27GXpf02",
"name": "Taylor Swift",
"type": "artist",
"uri": "spotify:artist:06HL4z0CvFAxyc27GXpf02"
},
{
"external_urls": {
"spotify": "https://open.spotify.com/artist/6eUKZXaKkcviH0Ku9w2n3V"
},
"href": "https://api.spotify.com/v1/artists/6eUKZXaKkcviH0Ku9w2n3V",
"id": "6eUKZXaKkcviH0Ku9w2n3V",
"name": "Ed Sheeran",
"type": "artist",
"uri": "spotify:artist:6eUKZXaKkcviH0Ku9w2n3V"
},
{
"external_urls": {
"spotify": "https://open.spotify.com/artist/1RyvyyTE3xzB2ZywiAwp0i"
},
"href": "https://api.spotify.com/v1/artists/1RyvyyTE3xzB2ZywiAwp0i",
"id": "1RyvyyTE3xzB2ZywiAwp0i",
"name": "Future",
"type": "artist",
"uri": "spotify:artist:1RyvyyTE3xzB2ZywiAwp0i"
}
],
"disc_number": 1,
"duration_ms": 244826,
"explicit": false,
"external_urls": {
"spotify": "https://open.spotify.com/track/2x0WlnmfG39ZuDmstl9xfX"
},
"href": "https://api.spotify.com/v1/tracks/2x0WlnmfG39ZuDmstl9xfX",
"id": "2x0WlnmfG39ZuDmstl9xfX",
"is_local": false,
"is_playable": true,
"name": "End Game",
"preview_url": "https://p.scdn.co/mp3-preview/908f388e5550f9d6d940ef721eb6d302770f0117?cid=cfe923b2d660439caf2b557b21f31221",
"track_number": 2,
"type": "track",
"uri": "spotify:track:2x0WlnmfG39ZuDmstl9xfX"
},
{
"artists": [
{
"external_urls": {
"spotify": "https://open.spotify.com/artist/06HL4z0CvFAxyc27GXpf02"
},
"href": "https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02",
"id": "06HL4z0CvFAxyc27GXpf02",
"name": "Taylor Swift",
"type": "artist",
"uri": "spotify:artist:06HL4z0CvFAxyc27GXpf02"
}
],
"disc_number": 1,
"duration_ms": 238253,
"explicit": false,
"external_urls": {
"spotify": "https://open.spotify.com/track/4svZDCRz4cJoneBpjpx8DJ"
},
"href": "https://api.spotify.com/v1/tracks/4svZDCRz4cJoneBpjpx8DJ",
"id": "4svZDCRz4cJoneBpjpx8DJ",
"is_local": false,
"is_playable": true,
"name": "I Did Something Bad",
"preview_url": "https://p.scdn.co/mp3-preview/ef43901885fc52988f3192152a8019fc7a34f0d5?cid=cfe923b2d660439caf2b557b21f31221",
"track_number": 3,
"type": "track",
"uri": "spotify:track:4svZDCRz4cJoneBpjpx8DJ"
}
],
"limit": 3,
"next": "https://api.spotify.com/v1/albums/6DEjYFkNZh67HP7R9PSZvv/tracks?offset=3&limit=3&locale=de,en-US;q%3D0.7,en;q%3D0.3",
"offset": 0,
"previous": null,
"total": 15
}' readStream
]

{
Expand Down
2 changes: 1 addition & 1 deletion src/SpotifyConnect/SPOCImage.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ SPOCImage class >> newWithUrl: aString [

{
#category : #testing,
#'squeak_changestamp' : 'TL 6/12/2024 01:12'
#'squeak_changestamp' : 'TL 6/23/2024 16:28'
}
SPOCImage >> equals: anImage [

Expand Down
88 changes: 88 additions & 0 deletions src/SpotifyConnect/SPOCMockTestApiAlbum.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
Class {
#name : #SPOCMockTestApiAlbum,
#superclass : #TestCase,
#instVars : [
'apiEndpoint',
'track'
],
#category : #'SpotifyConnect-Mock-Tests'
}

{
#category : #accessing,
#'squeak_changestamp' : 'TL 6/23/2024 15:50'
}
SPOCMockTestApiAlbum >> apiEndpoint [

^ apiEndpoint
]

{
#category : #accessing,
#'squeak_changestamp' : 'TL 6/23/2024 15:50'
}
SPOCMockTestApiAlbum >> apiEndpoint: anObject [

apiEndpoint := anObject
]

{
#category : #setup,
#'squeak_changestamp' : 'TL 6/23/2024 16:16'
}
SPOCMockTestApiAlbum >> artists [

^ {(SPOCArtist new
id: '06HL4z0CvFAxyc27GXpf02';
name: 'Taylor Swift';
yourself)} asOrderedCollection
]

{
#category : #setup,
#'squeak_changestamp' : 'TL 6/23/2024 16:22'
}
SPOCMockTestApiAlbum >> setUp [

self apiEndpoint: (SPOCApiAlbum new returnsTestContent: true);
track: (SPOCTrack new
id: '2yLa0QULdQr0qAIvVwN6B5';
name: '...Ready For It?';
image: nil;
album: nil;
artists: self artists;
duration: 208;
trackNumber: 1;
yourself).
]

{
#category : #testing,
#'squeak_changestamp' : 'TL 6/23/2024 16:27'
}
SPOCMockTestApiAlbum >> testMockApiAlbumExecute [

| res |
res := self apiEndpoint execute: (Dictionary new).
res first image: nil;
album: nil.
self assert: (res first equals: self track)
]

{
#category : #accessing,
#'squeak_changestamp' : 'TL 6/23/2024 16:03'
}
SPOCMockTestApiAlbum >> track [

^ track
]

{
#category : #accessing,
#'squeak_changestamp' : 'TL 6/23/2024 16:03'
}
SPOCMockTestApiAlbum >> track: anObject [

track := anObject
]
17 changes: 8 additions & 9 deletions src/SpotifyConnect/SPOCSearchbar.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -256,18 +256,17 @@ SPOCSearchbar >> sanitizeInput: aString [

{
#category : #'api-call',
#'squeak_changestamp' : 'TL 6/23/2024 15:38'
#'squeak_changestamp' : 'TL 6/23/2024 16:13'
}
SPOCSearchbar >> search: aString [

| apiEndpoint |
self app updatePlaybackState.
self disabled
ifFalse: [apiEndpoint := SPOCApiSearch new
authorizer: self app auth;
yourself.
self input: aString;
results: (apiEndpoint search: (self sanitizeInput: aString) withFilter: self filter).
self app resultList updateResults: self results;
title: 'Your Results']
apiEndpoint := SPOCApiSearch new
authorizer: self app auth;
yourself.
self input: aString;
results: (apiEndpoint search: (self sanitizeInput: aString) withFilter: self filter).
self app resultList updateResults: self results;
title: 'Your Results'
]
Loading

0 comments on commit 6c15097

Please sign in to comment.