Skip to content

Commit

Permalink
Started request class with test file. Skipping http dependent tests u…
Browse files Browse the repository at this point in the history
…ntil I figure out how to test it correctly.
  • Loading branch information
Chavez committed Mar 17, 2012
1 parent a42878b commit d07f580
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
37 changes: 37 additions & 0 deletions al_papi/request.py
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


14 changes: 14 additions & 0 deletions tests/unit/test_request.py
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()

0 comments on commit d07f580

Please sign in to comment.