Skip to content

Commit

Permalink
Adding post_json and put_json helpers.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkrimer committed May 6, 2016
1 parent a4bd683 commit 6f2d4ac
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
23 changes: 20 additions & 3 deletions common/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import http.client

from os import path
from operator import itemgetter
from flask.json import dumps
from flask.testing import FlaskClient
from flask.wrappers import Response
Expand Down Expand Up @@ -42,20 +41,38 @@ def __init__(self, *args, **kwargs):
self.trace_ok = assert_response_ok(self.trace)
self.options_ok = assert_response_ok(self.options)

def post_json_ok(self, url, payload):
def post_json(self, url, payload):
"""
Send a POST request with JSON content in the body.
"""

return self.post(url,
content_type='application/json',
data=dumps(payload, indent=2))

def post_json_ok(self, url, payload):
"""
Send a POST request with JSON content in the body and verify that HTTP 200 comes back.
"""

return self.post_ok(url,
content_type='application/json',
data=dumps(payload, indent=2))

def put_json_ok(self, url, payload):
def put_json(self, url, payload):
"""
Send a PUT request with JSON content in the body.
"""

return self.put(url,
content_type='application/json',
data=dumps(payload, indent=2))

def put_json_ok(self, url, payload):
"""
Send a PUT request with JSON content in the body and verify that HTTP 200 comes back.
"""

return self.put_ok(url,
content_type='application/json',
data=dumps(payload, indent=2))
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup

setup(name='common',
version='0.1.8',
version='0.1.9',
author='Unascribed',
author_email='[email protected]',
description='Code intended to be used across Polymath Ventures repositories.',
Expand Down

0 comments on commit 6f2d4ac

Please sign in to comment.