Skip to content

Updated supported Python, Django and DRF version #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
dist: xenial
language: python

python:
- "2.7"
- "3.4"
- "3.5"
- 2.7
- 3.5
- 3.6
- 3.7

env:
- DJANGO_VERSION=1.8
- DJANGO_VERSION=1.9
- DJANGO_VERSION=1.10
- DJANGO_VERSION=">=1.11,<2"
- DJANGO_VERSION=">=2.1,<2.2"
- DJANGO_VERSION=">=2.2,<2.3"
- DRF_VERSION=">=3.8,<3.9"
- DRF_VERSION=">3.9,<3.10"

matrix:
exclude:
- python: 2.7
env: DJANGO_VERSION=">=2.1,<2.2"
- python: 2.7
env: DJANGO_VERSION=">=2.2,<2.3"

install:
- pip install -q Django==$DJANGO_VERSION
- pip install -q -r requirements.txt
- pip install -q "msgpack>=0.6.1" "python-dateutil>=2.8"
- pip install "djangorestframework${DRF_VERSION}" "django${DJANGO_VERSION}"

script: python manage.py test
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Django>=1.8
djangorestframework>=2.1.15
msgpack-python>=0.2.4
python-dateutil>=2.1
Django>=1.11
djangorestframework>=3.9,<3.10
msgpack>=0.6.1
python-dateutil>=2.8
24 changes: 23 additions & 1 deletion rest_framework_msgpack/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
import datetime
from io import BytesIO
from django.test import TestCase
from rest_framework_msgpack.renderers import MessagePackRenderer

from rest_framework.exceptions import ParseError

from rest_framework_msgpack.renderers import MessagePackRenderer, MessagePackEncoder
from rest_framework_msgpack.parsers import MessagePackParser


Expand Down Expand Up @@ -74,3 +77,22 @@ def test_decimal(self):
content = renderer.render(obj, 'application/msgpack')
data = parser.parse(BytesIO(content))
self.assertEquals(obj, data)

def test_handle_invalid_payload(self):
invalid_msgpack_repr = b'\xa1\xa3foo\x92\xa3bar\xa4baz'
parser = MessagePackParser()
with self.assertRaises(ParseError):
parser.parse(invalid_msgpack_repr)

def test_handle_empty_data_render(self):
renderer = MessagePackRenderer()
self.assertEqual(renderer.render(data=None), '')

def test_renderer_not_encoding_unhandled_data(self):
encoder = MessagePackEncoder()

class DummyClass:
foo = 'bar'

dummy_instance = DummyClass()
self.assertEqual(encoder.encode(dummy_instance), dummy_instance)
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def get_package_data(package):
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Topic :: Internet :: WWW/HTTP'
]
)