diff --git a/.travis.yml b/.travis.yml index 5728fef..6f64f1e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/requirements.txt b/requirements.txt index 773c8f1..cbc1106 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/rest_framework_msgpack/tests.py b/rest_framework_msgpack/tests.py index 404b359..4ce175e 100755 --- a/rest_framework_msgpack/tests.py +++ b/rest_framework_msgpack/tests.py @@ -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 @@ -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) diff --git a/setup.py b/setup.py index e6560c5..1d4c039 100755 --- a/setup.py +++ b/setup.py @@ -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' ] )