Created
May 1, 2012 17:56
-
-
Save khoffrath/2570059 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
curl -i -H "Content-Type: application/json; charset=UTF-8" --request POST --data u"{'tag': u'Äüößäname'}" http://localhost:5000/ |
This file contains hidden or 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
# -*- 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() |
This file contains hidden or 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
# -*- 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