Skip to content

Instantly share code, notes, and snippets.

@khoffrath
Created May 1, 2012 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khoffrath/2570059 to your computer and use it in GitHub Desktop.
Save khoffrath/2570059 to your computer and use it in GitHub Desktop.
curl -i -H "Content-Type: application/json; charset=UTF-8" --request POST --data u"{'tag': u'Äüößäname'}" http://localhost:5000/
# -*- coding: utf-8 -*-
#__author__ = 'khoffrath'
import unittest
from unittest import TestCase
import unicode_post_srv
class UnicodePostServerTestCase(TestCase):
def setUp(self):
unicode_post_srv.app.config['TESTING'] = True
self.app = unicode_post_srv.app.test_client()
def test_get(self):
rv = self.app.get('/')
self.assertEqual(rv.status_code, 200)
self.assertTrue('GET' in rv.data)
def test_post(self):
rv = self.app.post('/')
self.assertEqual(rv.status_code, 200)
self.assertTrue('POST' in rv.data)
def test_put(self):
rv = self.app.put('/')
self.assertEqual(rv.status_code, 200)
self.assertTrue('PUT' in rv.data)
def test_delete(self):
rv = self.app.delete('/')
self.assertEqual(rv.status_code, 200)
self.assertTrue('DELETE' in rv.data)
def test_post_unicode_valid(self):
rv = self.app.post('/', data=u"{'tag': u'clean'}")
self.assertEqual(rv.status_code, 200)
self.assertTrue('POST' in rv.data)
#@unittest.skip('')
def test_post_unicode_invalid(self):
rv = self.app.post('/', data=u"{'tag': u'Äüößäname'}")
self.assertEqual(rv.status_code, 200)
self.assertTrue('POST' in rv.data)
if __name__ == '__main__':
unittest.main()
# -*- coding: utf-8 -*-
#__author__ = 'khoffrath'
import flask
app = flask.Flask(__name__)
@app.route('/', methods=['GET', 'POST', 'PUT', 'DELETE'])
def hello():
return 'HTTP verb: ' + flask.request.method
if __name__ == "__main__":
app.run(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment