-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started request class with test file. Skipping http dependent tests u…
…ntil I figure out how to test it correctly.
- Loading branch information
Chavez
committed
Mar 17, 2012
1 parent
a42878b
commit d07f580
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import al_papi | ||
from httplib2 import Http | ||
from urllib import urlencode | ||
|
||
class Request(object): | ||
""" | ||
docstring for Request | ||
""" | ||
@staticmethod | ||
def default_headers(): | ||
return { 'Content-type': 'application/json' } | ||
|
||
def __init__(self): | ||
self.success = None | ||
self.errors = [] | ||
|
||
def post(self, params = {}): | ||
http = Http() | ||
params.update( { "auth_token" : al_papi.Config.api_key } ) | ||
url = '%s/keywords.json?%s' % ( al_papi.Config.default_host, urlencode(params) ) | ||
resp, content = http.request(url, "POST", headers=al_papi.Request.default_headers()) | ||
print "RESPONSE" | ||
print resp | ||
print "CONTENT" | ||
print content | ||
|
||
def get(self, params = {}): | ||
http = Http() | ||
params.update( { "auth_token" : al_papi.Config.api_key } ) | ||
url = '%s/keywords/get.json?%s' % ( al_papi.Config.default_host, urlencode(params) ) | ||
resp, content = http.request(url, "GET", headers=al_papi.Request.default_headers()) | ||
print "RESPONSE" | ||
print resp | ||
print "CONTENT" | ||
print content | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from tests.test_helper import * | ||
|
||
class TestRequest(unittest.TestCase): | ||
|
||
def testInitSuccess(self): | ||
assert_equal(Request().success, None) | ||
|
||
def testInitErrors(self): | ||
assert_equal(Request().errors, []) | ||
|
||
@unittest.skip("Figure out test with http requests") | ||
def testPost(self): | ||
assert_true() | ||
|