@@ -28,10 +28,7 @@ mod mock {
28
28
let mut p = response. request. url( ) . query_pairs( ) ;
29
29
assert_eq!( p. count( ) , 2 ) ;
30
30
assert_eq!( p. next( ) , Some ( ( Cow :: Borrowed ( "q" ) , Cow :: Borrowed ( "dummy" ) ) ) ) ;
31
- assert_eq!(
32
- p. next( ) ,
33
- Some ( ( Cow :: Borrowed ( "sort_by_date" ) , Cow :: Borrowed ( "1" ) ) )
34
- ) ;
31
+ assert_eq!( p. next( ) , Some ( ( Cow :: Borrowed ( "sort_by_date" ) , Cow :: Borrowed ( "1" ) ) ) ) ;
35
32
// Response
36
33
let body = response. json( ) . await . unwrap( ) ;
37
34
assert!( body. is_object( ) ) ;
@@ -71,10 +68,7 @@ mod mock {
71
68
let mut p = response. request. url( ) . query_pairs( ) ;
72
69
assert_eq!( p. count( ) , 2 ) ;
73
70
assert_eq!( p. next( ) , Some ( ( Cow :: Borrowed ( "q" ) , Cow :: Borrowed ( "dummy" ) ) ) ) ;
74
- assert_eq!(
75
- p. next( ) ,
76
- Some ( ( Cow :: Borrowed ( "show_podcasts" ) , Cow :: Borrowed ( "1" ) ) )
77
- ) ;
71
+ assert_eq!( p. next( ) , Some ( ( Cow :: Borrowed ( "show_podcasts" ) , Cow :: Borrowed ( "1" ) ) ) ) ;
78
72
// Response
79
73
let body = response. json( ) . await . unwrap( ) ;
80
74
assert!( body. is_object( ) ) ;
@@ -96,10 +90,7 @@ mod mock {
96
90
assert_eq!( response. request. url( ) . path( ) , "/api/v2/best_podcasts" ) ;
97
91
let mut p = response. request. url( ) . query_pairs( ) ;
98
92
assert_eq!( p. count( ) , 1 ) ;
99
- assert_eq!(
100
- p. next( ) ,
101
- Some ( ( Cow :: Borrowed ( "genre_id" ) , Cow :: Borrowed ( "23" ) ) )
102
- ) ;
93
+ assert_eq!( p. next( ) , Some ( ( Cow :: Borrowed ( "genre_id" ) , Cow :: Borrowed ( "23" ) ) ) ) ;
103
94
// Response
104
95
let body = response. json( ) . await . unwrap( ) ;
105
96
assert!( body. is_object( ) ) ;
@@ -110,10 +101,7 @@ mod mock {
110
101
#[ test]
111
102
fn fetch_podcast_by_id ( ) {
112
103
b ! ( async {
113
- let response = client( )
114
- . fetch_podcast_by_id( "dummy_id" , & json!( { } ) )
115
- . await
116
- . unwrap( ) ;
104
+ let response = client( ) . fetch_podcast_by_id( "dummy_id" , & json!( { } ) ) . await . unwrap( ) ;
117
105
// Request
118
106
assert_eq!( response. request. method( ) , http:: Method :: GET ) ;
119
107
assert_eq!( response. request. url( ) . path( ) , "/api/v2/podcasts/dummy_id" ) ;
@@ -138,8 +126,7 @@ mod mock {
138
126
// Request
139
127
assert_eq!( response. request. method( ) , http:: Method :: POST ) ;
140
128
assert_eq!( response. request. url( ) . path( ) , "/api/v2/podcasts" ) ;
141
- let mut p =
142
- form_urlencoded:: parse( response. request. body( ) . unwrap( ) . as_bytes( ) . unwrap( ) ) ;
129
+ let mut p = form_urlencoded:: parse( response. request. body( ) . unwrap( ) . as_bytes( ) . unwrap( ) ) ;
143
130
assert_eq!( p. count( ) , 1 ) ;
144
131
assert_eq!(
145
132
p. next( ) ,
@@ -155,10 +142,7 @@ mod mock {
155
142
#[ test]
156
143
fn fetch_episode_by_id ( ) {
157
144
b ! ( async {
158
- let response = client( )
159
- . fetch_episode_by_id( "dummy_id" , & json!( { } ) )
160
- . await
161
- . unwrap( ) ;
145
+ let response = client( ) . fetch_episode_by_id( "dummy_id" , & json!( { } ) ) . await . unwrap( ) ;
162
146
// Request
163
147
assert_eq!( response. request. method( ) , http:: Method :: GET ) ;
164
148
assert_eq!( response. request. url( ) . path( ) , "/api/v2/episodes/dummy_id" ) ;
@@ -167,13 +151,7 @@ mod mock {
167
151
// Response
168
152
let body = response. json( ) . await . unwrap( ) ;
169
153
assert!( body. is_object( ) ) ;
170
- assert!(
171
- body[ "podcast" ] . as_object( ) . unwrap( ) [ "rss" ]
172
- . as_str( )
173
- . unwrap( )
174
- . len( )
175
- > 0
176
- ) ;
154
+ assert!( body[ "podcast" ] . as_object( ) . unwrap( ) [ "rss" ] . as_str( ) . unwrap( ) . len( ) > 0 ) ;
177
155
} ) ;
178
156
}
179
157
@@ -189,8 +167,7 @@ mod mock {
189
167
// Request
190
168
assert_eq!( response. request. method( ) , http:: Method :: POST ) ;
191
169
assert_eq!( response. request. url( ) . path( ) , "/api/v2/episodes" ) ;
192
- let mut p =
193
- form_urlencoded:: parse( response. request. body( ) . unwrap( ) . as_bytes( ) . unwrap( ) ) ;
170
+ let mut p = form_urlencoded:: parse( response. request. body( ) . unwrap( ) . as_bytes( ) . unwrap( ) ) ;
194
171
assert_eq!( p. count( ) , 1 ) ;
195
172
assert_eq!(
196
173
p. next( ) ,
@@ -202,4 +179,115 @@ mod mock {
202
179
assert!( body[ "episodes" ] . as_array( ) . unwrap( ) . len( ) > 0 ) ;
203
180
} ) ;
204
181
}
182
+
183
+ #[ test]
184
+ fn fetch_curated_podcasts_list_by_id ( ) {
185
+ b ! ( async {
186
+ let response = client( )
187
+ . fetch_curated_podcasts_list_by_id( "asdfsdaf" , & json!( { } ) )
188
+ . await
189
+ . unwrap( ) ;
190
+ // Request
191
+ assert_eq!( response. request. method( ) , http:: Method :: GET ) ;
192
+ assert_eq!( response. request. url( ) . path( ) , "/api/v2/curated_podcasts/asdfsdaf" ) ;
193
+ let p = response. request. url( ) . query_pairs( ) ;
194
+ assert_eq!( p. count( ) , 0 ) ;
195
+ // Response
196
+ let body = response. json( ) . await . unwrap( ) ;
197
+ assert!( body. is_object( ) ) ;
198
+ assert!( body[ "podcasts" ] . as_array( ) . unwrap( ) . len( ) > 0 ) ;
199
+ } ) ;
200
+ }
201
+
202
+ #[ test]
203
+ fn fetch_curated_podcasts_lists ( ) {
204
+ b ! ( async {
205
+ let response = client( )
206
+ . fetch_curated_podcasts_lists( & json!( {
207
+ "page" : 2
208
+ } ) )
209
+ . await
210
+ . unwrap( ) ;
211
+ // Request
212
+ assert_eq!( response. request. method( ) , http:: Method :: GET ) ;
213
+ assert_eq!( response. request. url( ) . path( ) , "/api/v2/curated_podcasts" ) ;
214
+ let mut p = response. request. url( ) . query_pairs( ) ;
215
+ assert_eq!( p. count( ) , 1 ) ;
216
+ assert_eq!( p. next( ) , Some ( ( Cow :: Borrowed ( "page" ) , Cow :: Borrowed ( "2" ) ) ) ) ;
217
+ // Response
218
+ let body = response. json( ) . await . unwrap( ) ;
219
+ assert!( body. is_object( ) ) ;
220
+ assert!( body[ "total" ] . as_i64( ) . unwrap( ) > 0 ) ;
221
+ } ) ;
222
+ }
223
+
224
+ #[ test]
225
+ fn fetch_podcast_genres ( ) {
226
+ b ! ( async {
227
+ let response = client( )
228
+ . fetch_podcast_genres( & json!( {
229
+ "top_level_only" : 1
230
+ } ) )
231
+ . await
232
+ . unwrap( ) ;
233
+ // Request
234
+ assert_eq!( response. request. method( ) , http:: Method :: GET ) ;
235
+ assert_eq!( response. request. url( ) . path( ) , "/api/v2/genres" ) ;
236
+ let mut p = response. request. url( ) . query_pairs( ) ;
237
+ assert_eq!( p. count( ) , 1 ) ;
238
+ assert_eq!( p. next( ) , Some ( ( Cow :: Borrowed ( "top_level_only" ) , Cow :: Borrowed ( "1" ) ) ) ) ;
239
+ // Response
240
+ let body = response. json( ) . await . unwrap( ) ;
241
+ assert!( body. is_object( ) ) ;
242
+ assert!( body[ "genres" ] . as_array( ) . unwrap( ) . len( ) > 0 ) ;
243
+ } ) ;
244
+ }
245
+
246
+ #[ test]
247
+ fn fetch_podcast_regions ( ) {
248
+ b ! ( async {
249
+ let response = client( ) . fetch_podcast_regions( & json!( { } ) ) . await . unwrap( ) ;
250
+ // Request
251
+ assert_eq!( response. request. method( ) , http:: Method :: GET ) ;
252
+ assert_eq!( response. request. url( ) . path( ) , "/api/v2/regions" ) ;
253
+ let p = response. request. url( ) . query_pairs( ) ;
254
+ assert_eq!( p. count( ) , 0 ) ;
255
+ // Response
256
+ let body = response. json( ) . await . unwrap( ) ;
257
+ assert!( body. is_object( ) ) ;
258
+ assert!( body[ "regions" ] . as_object( ) . unwrap( ) . keys( ) . len( ) > 0 ) ;
259
+ } ) ;
260
+ }
261
+
262
+ #[ test]
263
+ fn fetch_podcast_languages ( ) {
264
+ b ! ( async {
265
+ let response = client( ) . fetch_podcast_languages( & json!( { } ) ) . await . unwrap( ) ;
266
+ // Request
267
+ assert_eq!( response. request. method( ) , http:: Method :: GET ) ;
268
+ assert_eq!( response. request. url( ) . path( ) , "/api/v2/languages" ) ;
269
+ let p = response. request. url( ) . query_pairs( ) ;
270
+ assert_eq!( p. count( ) , 0 ) ;
271
+ // Response
272
+ let body = response. json( ) . await . unwrap( ) ;
273
+ assert!( body. is_object( ) ) ;
274
+ assert!( body[ "languages" ] . as_array( ) . unwrap( ) . len( ) > 0 ) ;
275
+ } ) ;
276
+ }
277
+
278
+ #[ test]
279
+ fn just_listen ( ) {
280
+ b ! ( async {
281
+ let response = client( ) . just_listen( & json!( { } ) ) . await . unwrap( ) ;
282
+ // Request
283
+ assert_eq!( response. request. method( ) , http:: Method :: GET ) ;
284
+ assert_eq!( response. request. url( ) . path( ) , "/api/v2/just_listen" ) ;
285
+ let p = response. request. url( ) . query_pairs( ) ;
286
+ assert_eq!( p. count( ) , 0 ) ;
287
+ // Response
288
+ let body = response. json( ) . await . unwrap( ) ;
289
+ assert!( body. is_object( ) ) ;
290
+ assert!( body[ "audio_length_sec" ] . as_i64( ) . unwrap( ) > 0 ) ;
291
+ } ) ;
292
+ }
205
293
}
0 commit comments