@@ -11,6 +11,8 @@ import com.adamratzman.spotify.utils.Locale
11
11
import com.adamratzman.spotify.utils.Market
12
12
import com.adamratzman.spotify.utils.getCurrentTimeMs
13
13
import kotlin.test.Test
14
+ import kotlin.test.assertEquals
15
+ import kotlin.test.assertNotEquals
14
16
import kotlin.test.assertNotNull
15
17
import kotlin.test.assertNotSame
16
18
import kotlin.test.assertTrue
@@ -37,8 +39,8 @@ class BrowseApiTest {
37
39
if (! testPrereq()) return @runBlockingTest
38
40
39
41
assertNotSame(
40
- api.browse.getCategoryList(locale = Locale .ar_AE).items[0 ],
41
- api.browse.getCategoryList().items[0 ]
42
+ api.browse.getCategoryList(locale = Locale .ar_AE).items[0 ],
43
+ api.browse.getCategoryList().items[0 ]
42
44
)
43
45
assertTrue(api.browse.getCategoryList(4 , 3 , market = Market .CA ).items.isNotEmpty())
44
46
assertTrue(api.browse.getCategoryList(4 , 3 , locale = Locale .fr_FR, market = Market .CA ).items.isNotEmpty())
@@ -62,7 +64,12 @@ class BrowseApiTest {
62
64
runBlockingTest {
63
65
if (! testPrereq()) return @runBlockingTest
64
66
65
- assertFailsWithSuspend<SpotifyException .BadRequestException > { api.browse.getPlaylistsForCategory(" no u" , limit = 4 ) }
67
+ assertFailsWithSuspend<SpotifyException .BadRequestException > {
68
+ api.browse.getPlaylistsForCategory(
69
+ " no u" ,
70
+ limit = 4
71
+ )
72
+ }
66
73
assertTrue(api.browse.getPlaylistsForCategory(" pop" , 10 , 0 , Market .FR ).items.isNotEmpty())
67
74
}
68
75
}
@@ -73,12 +80,12 @@ class BrowseApiTest {
73
80
if (! testPrereq()) return @runBlockingTest
74
81
75
82
assertTrue(
76
- api.browse.getFeaturedPlaylists(
77
- 5 ,
78
- 4 ,
79
- market = Market .US ,
80
- timestamp = getCurrentTimeMs() - 10000000
81
- ).playlists.total > 0
83
+ api.browse.getFeaturedPlaylists(
84
+ 5 ,
85
+ 4 ,
86
+ market = Market .US ,
87
+ timestamp = getCurrentTimeMs() - 10000000
88
+ ).playlists.total > 0
82
89
)
83
90
assertTrue(api.browse.getFeaturedPlaylists(offset = 32 ).playlists.total > 0 )
84
91
}
@@ -107,102 +114,114 @@ class BrowseApiTest {
107
114
}
108
115
assertTrue(api.browse.getTrackRecommendations(seedArtists = listOf (" 2C2sVVXanbOpymYBMpsi89" )).tracks.isNotEmpty())
109
116
assertTrue(
110
- api.browse.getTrackRecommendations(
111
- seedArtists = listOf (
112
- " 2C2sVVXanbOpymYBMpsi89" ,
113
- " 7lMgpN1tEBQKpRoUMKB8iw"
114
- )
115
- ).tracks.isNotEmpty()
117
+ api.browse.getTrackRecommendations(
118
+ seedArtists = listOf (
119
+ " 2C2sVVXanbOpymYBMpsi89" ,
120
+ " 7lMgpN1tEBQKpRoUMKB8iw"
121
+ )
122
+ ).tracks.isNotEmpty()
116
123
)
117
124
118
125
assertFailsWithSuspend<SpotifyException .BadRequestException > {
119
126
api.browse.getTrackRecommendations(seedTracks = listOf (" abc" ))
120
127
}
121
128
assertTrue(api.browse.getTrackRecommendations(seedTracks = listOf (" 3Uyt0WO3wOopnUBCe9BaXl" )).tracks.isNotEmpty())
122
129
assertTrue(
123
- api.browse.getTrackRecommendations(
124
- seedTracks = listOf (
125
- " 6d9iYQG2JvTTEgcndW81lt" ,
126
- " 3Uyt0WO3wOopnUBCe9BaXl"
127
- )
128
- ).tracks.isNotEmpty()
130
+ api.browse.getTrackRecommendations(
131
+ seedTracks = listOf (
132
+ " 6d9iYQG2JvTTEgcndW81lt" ,
133
+ " 3Uyt0WO3wOopnUBCe9BaXl"
134
+ )
135
+ ).tracks.isNotEmpty()
129
136
)
130
137
131
138
api.browse.getTrackRecommendations(seedGenres = listOf (" abc" ))
132
139
assertTrue(api.browse.getTrackRecommendations(seedGenres = listOf (" pop" )).tracks.isNotEmpty())
133
140
assertTrue(
134
- api.browse.getTrackRecommendations(
135
- seedGenres = listOf (
136
- " pop" ,
137
- " latinx"
138
- )
139
- ).tracks.isNotEmpty()
141
+ api.browse.getTrackRecommendations(
142
+ seedGenres = listOf (
143
+ " pop" ,
144
+ " latinx"
145
+ )
146
+ ).tracks.isNotEmpty()
140
147
)
141
148
142
149
api.browse.getTrackRecommendations(
143
- seedArtists = listOf (" 2C2sVVXanbOpymYBMpsi89" ),
144
- seedTracks = listOf (" 6d9iYQG2JvTTEgcndW81lt" , " 3Uyt0WO3wOopnUBCe9BaXl" ),
145
- seedGenres = listOf (" pop" )
150
+ seedArtists = listOf (" 2C2sVVXanbOpymYBMpsi89" ),
151
+ seedTracks = listOf (" 6d9iYQG2JvTTEgcndW81lt" , " 3Uyt0WO3wOopnUBCe9BaXl" ),
152
+ seedGenres = listOf (" pop" )
146
153
)
147
154
148
155
assertFailsWithSuspend<IllegalArgumentException > {
149
156
api.browse.getTrackRecommendations(
150
- targetAttributes = listOf (
151
- TuneableTrackAttribute .Acousticness .asTrackAttribute(
152
- 3f
153
- )
157
+ targetAttributes = listOf (
158
+ TuneableTrackAttribute .Acousticness .asTrackAttribute(
159
+ 3f
154
160
)
161
+ )
155
162
)
156
163
}
157
164
assertTrue(
158
- api.browse.getTrackRecommendations(
159
- targetAttributes = listOf (
160
- TuneableTrackAttribute .Acousticness .asTrackAttribute(1f ),
161
- TuneableTrackAttribute .Danceability .asTrackAttribute(0.5f )
162
- ),
163
- seedGenres = listOf (" pop" )
164
- ).tracks.isNotEmpty()
165
+ api.browse.getTrackRecommendations(
166
+ targetAttributes = listOf (
167
+ TuneableTrackAttribute .Acousticness .asTrackAttribute(1f ),
168
+ TuneableTrackAttribute .Danceability .asTrackAttribute(0.5f )
169
+ ),
170
+ seedGenres = listOf (" pop" )
171
+ ).tracks.isNotEmpty()
165
172
)
166
173
167
174
assertFailsWithSuspend<IllegalArgumentException > {
168
175
api.browse.getTrackRecommendations(
169
- minAttributes = listOf (
170
- TuneableTrackAttribute .Acousticness .asTrackAttribute(
171
- 3f
172
- )
176
+ minAttributes = listOf (
177
+ TuneableTrackAttribute .Acousticness .asTrackAttribute(
178
+ 3f
173
179
)
180
+ )
174
181
)
175
182
}
176
183
assertTrue(
177
- api.browse.getTrackRecommendations(
178
- minAttributes = listOf (
179
- TuneableTrackAttribute .Acousticness .asTrackAttribute(0.5f ),
180
- TuneableTrackAttribute .Danceability .asTrackAttribute(0.5f )
181
- ),
182
- seedGenres = listOf (" pop" )
183
- ).tracks.isNotEmpty()
184
+ api.browse.getTrackRecommendations(
185
+ minAttributes = listOf (
186
+ TuneableTrackAttribute .Acousticness .asTrackAttribute(0.5f ),
187
+ TuneableTrackAttribute .Danceability .asTrackAttribute(0.5f )
188
+ ),
189
+ seedGenres = listOf (" pop" )
190
+ ).tracks.isNotEmpty()
184
191
)
185
192
186
193
assertFailsWithSuspend<SpotifyException .BadRequestException > {
187
194
api.browse.getTrackRecommendations(
188
- maxAttributes = listOf (
189
- TuneableTrackAttribute .Speechiness .asTrackAttribute(
190
- 0.9f
191
- )
195
+ maxAttributes = listOf (
196
+ TuneableTrackAttribute .Speechiness .asTrackAttribute(
197
+ 0.9f
192
198
)
199
+ )
193
200
)
194
201
}
195
202
assertTrue(
196
- api.browse.getTrackRecommendations(
197
- maxAttributes = listOf (
198
- TuneableTrackAttribute .Acousticness .asTrackAttribute(0.9f ),
199
- TuneableTrackAttribute .Danceability .asTrackAttribute(0.9f )
200
- ),
201
- seedGenres = listOf (" pop" )
202
- ).tracks.isNotEmpty()
203
+ api.browse.getTrackRecommendations(
204
+ maxAttributes = listOf (
205
+ TuneableTrackAttribute .Acousticness .asTrackAttribute(0.9f ),
206
+ TuneableTrackAttribute .Danceability .asTrackAttribute(0.9f )
207
+ ),
208
+ seedGenres = listOf (" pop" )
209
+ ).tracks.isNotEmpty()
203
210
)
204
211
205
212
assertTrue(TuneableTrackAttribute .values().first().asTrackAttribute(0f ).value == 0f )
206
213
}
207
214
}
215
+
216
+ @Test
217
+ fun testTuneableTrackAttributeTypes () {
218
+ val float1: TuneableTrackAttribute <* > = TuneableTrackAttribute .Speechiness
219
+ val float2: TuneableTrackAttribute <* > = TuneableTrackAttribute .Acousticness
220
+ val int1: TuneableTrackAttribute <* > = TuneableTrackAttribute .Key
221
+ val int2: TuneableTrackAttribute <* > = TuneableTrackAttribute .Popularity
222
+
223
+ assertEquals(float1.typeClass, float2.typeClass)
224
+ assertEquals(int1.typeClass, int2.typeClass)
225
+ assertNotEquals(float1.typeClass, int1.typeClass)
226
+ }
208
227
}
0 commit comments