@@ -763,8 +763,38 @@ def test_APIPutWithSimpleQuery(self):
763
763
self .assertEqual (response_obj ['product' ]['title' ], str (nonce ))
764
764
self .assertEqual (request_params ['filter[limit]' ], str (5 ))
765
765
766
+ @unittest .skipIf (platform .uname ()[1 ] != "Ich.lan" , "should only work on my machine" )
766
767
class WPAPITestCases (unittest .TestCase ):
767
- pass
768
+ def setUp (self ):
769
+ self .apiParams = {
770
+ 'url' :'http://ich.local:8888/woocommerce/' ,
771
+ 'api' :'wp-json' ,
772
+ 'version' :'wp/v2' ,
773
+ 'consumer_key' :'kGUDYhYPNTTq' ,
774
+ 'consumer_secret' :'44fhpRsd0yo5deHaUSTZUtHgamrKwARzV8JUgTbGu61qrI0i' ,
775
+ 'callback' :'http://127.0.0.1/oauth1_callback' ,
776
+ 'wp_user' :'woocommerce' ,
777
+ 'wp_pass' :'woocommerce' ,
778
+ 'oauth1a_3leg' :True
779
+ }
780
+
781
+ @debug_on ()
782
+ def test_APIGet (self ):
783
+ wpapi = API (** self .apiParams )
784
+ response = wpapi .get ('users' )
785
+ self .assertIn (response .status_code , [200 ,201 ])
786
+ response_obj = response .json ()
787
+ self .assertEqual (response_obj [0 ]['name' ], 'woocommerce' )
788
+
789
+ def test_APIGetWithSimpleQuery (self ):
790
+ wpapi = API (** self .apiParams )
791
+ response = wpapi .get ('media?page=2' )
792
+ # print UrlUtils.beautify_response(response)
793
+ self .assertIn (response .status_code , [200 ,201 ])
794
+
795
+ response_obj = response .json ()
796
+ self .assertEqual (len (response_obj ), 10 )
797
+ # print "test_ApiGenWithSimpleQuery", response_obj
768
798
769
799
770
800
if __name__ == '__main__' :
0 commit comments