@@ -28,10 +28,7 @@ mod mock {
2828 let mut p = response. request. url( ) . query_pairs( ) ;
2929 assert_eq!( p. count( ) , 2 ) ;
3030 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" ) ) ) ) ;
3532 // Response
3633 let body = response. json( ) . await . unwrap( ) ;
3734 assert!( body. is_object( ) ) ;
@@ -71,10 +68,7 @@ mod mock {
7168 let mut p = response. request. url( ) . query_pairs( ) ;
7269 assert_eq!( p. count( ) , 2 ) ;
7370 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" ) ) ) ) ;
7872 // Response
7973 let body = response. json( ) . await . unwrap( ) ;
8074 assert!( body. is_object( ) ) ;
@@ -96,10 +90,7 @@ mod mock {
9690 assert_eq!( response. request. url( ) . path( ) , "/api/v2/best_podcasts" ) ;
9791 let mut p = response. request. url( ) . query_pairs( ) ;
9892 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" ) ) ) ) ;
10394 // Response
10495 let body = response. json( ) . await . unwrap( ) ;
10596 assert!( body. is_object( ) ) ;
@@ -110,10 +101,7 @@ mod mock {
110101 #[ test]
111102 fn fetch_podcast_by_id ( ) {
112103 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( ) ;
117105 // Request
118106 assert_eq!( response. request. method( ) , http:: Method :: GET ) ;
119107 assert_eq!( response. request. url( ) . path( ) , "/api/v2/podcasts/dummy_id" ) ;
@@ -138,8 +126,7 @@ mod mock {
138126 // Request
139127 assert_eq!( response. request. method( ) , http:: Method :: POST ) ;
140128 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( ) ) ;
143130 assert_eq!( p. count( ) , 1 ) ;
144131 assert_eq!(
145132 p. next( ) ,
@@ -155,10 +142,7 @@ mod mock {
155142 #[ test]
156143 fn fetch_episode_by_id ( ) {
157144 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( ) ;
162146 // Request
163147 assert_eq!( response. request. method( ) , http:: Method :: GET ) ;
164148 assert_eq!( response. request. url( ) . path( ) , "/api/v2/episodes/dummy_id" ) ;
@@ -167,13 +151,7 @@ mod mock {
167151 // Response
168152 let body = response. json( ) . await . unwrap( ) ;
169153 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 ) ;
177155 } ) ;
178156 }
179157
@@ -189,8 +167,7 @@ mod mock {
189167 // Request
190168 assert_eq!( response. request. method( ) , http:: Method :: POST ) ;
191169 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( ) ) ;
194171 assert_eq!( p. count( ) , 1 ) ;
195172 assert_eq!(
196173 p. next( ) ,
@@ -202,4 +179,115 @@ mod mock {
202179 assert!( body[ "episodes" ] . as_array( ) . unwrap( ) . len( ) > 0 ) ;
203180 } ) ;
204181 }
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+ }
205293}
0 commit comments