Merge branch 'theoperatore-cors-headers-api'

This commit is contained in:
phalt 2014-12-15 10:04:14 +00:00
commit 3b38fe9aeb
5 changed files with 34 additions and 2 deletions

View file

@ -12,7 +12,8 @@ serve:
python manage.py runserver --settings=config.local
test:
python manage.py test pokemon --settings=config.local
python manage.py test pokemon_v1 --settings=config.local
python manage.py test pokemon_v2 --settings=config.local
clean:
rm -rf *.pyc

View file

@ -4,7 +4,6 @@ import os
PROJECT_ROOT = Path(__file__).ancestor(2)
DEBUG = False
TEMPLATE_DEBUG = DEBUG
@ -62,6 +61,7 @@ TEMPLATE_LOADERS = (
)
MIDDLEWARE_CLASSES = (
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
@ -119,9 +119,15 @@ INSTALLED_APPS = (
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.humanize',
'corsheaders'
) + CUSTOM_APPS
API_LIMIT_PER_PAGE = 1
TASTYPIE_DEFAULT_FORMATS = ['json', 'xml']
CORS_ORIGIN_ALLOW_ALL = True
CORS_ALLOW_METHODS = (
'GET'
)

View file

@ -1,2 +1,14 @@
from __future__ import unicode_literals
from django.test import TestCase
class HeaderTest(TestCase):
def test_pokemon(self):
response = self.client.get(
'/api/v1/pokemon/1/',
HTTP_ORIGIN="http://pokemon.com"
)
self.assertEqual(response['Access-Control-Allow-Origin'], '*')

View file

@ -2,3 +2,15 @@ from __future__ import unicode_literals
from django.test import TestCase
# Create your tests here.
class HeaderTest(TestCase):
def test_pokemon(self):
response = self.client.get(
'/api/v2/pokemon/1/',
HTTP_ORIGIN="http://pokemon.com"
)
self.assertEqual(response['Access-Control-Allow-Origin'], '*')

View file

@ -17,3 +17,4 @@ python-mimeparse==0.1.4
simplejson==3.6.5
six==1.8.0
wsgiref==0.1.2
django-cors-headers=0.13