8000 extra test cases specifically for WP · jamesbrink/wp-api-python@de39a8a · GitHub
[go: up one dir, main page]

Skip to content

Commit de39a8a

Browse files
author
derwentx
committed
extra test cases specifically for WP
1 parent d72779e commit de39a8a

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

tests.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,8 +763,38 @@ def test_APIPutWithSimpleQuery(self):
763763
self.assertEqual(response_obj['product']['title'], str(nonce))
764764
self.assertEqual(request_params['filter[limit]'], str(5))
765765

766+
@unittest.skipIf(platform.uname()[1] != "Ich.lan", "should only work on my machine")
766767
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
768798

769799

770800
if __name__ == '__main__':

0 commit comments

Comments
 (0)
0