Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
updated test requirements and a test for #9
Updates testing to use django 1.8/1.9. Also adds a test to make sure that
allow_null, and other args are correctly passed when many=True
  • Loading branch information
heywbj committed Dec 17, 2015
1 parent 69ff998 commit 3821fd2
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
6 changes: 3 additions & 3 deletions requirements.txt
Expand Up @@ -3,9 +3,9 @@ Django>=1.6
djangorestframework>=3.0.0

# Test requirements
pytest-django==2.6
pytest==2.5.2
pytest-cov==1.6
pytest-django==2.9.1
pytest==2.8.5
pytest-cov==2.2.0

# wheel for PyPI installs
wheel==0.24.0
28 changes: 28 additions & 0 deletions tests/test_recursive.py
Expand Up @@ -13,6 +13,11 @@ class NodeSerializer(serializers.Serializer):
children = serializers.ListField(child=RecursiveField())


class ManyNullSerializer(serializers.Serializer):
name = serializers.CharField()
children = RecursiveField(required=False, allow_null=True, many=True)


class PingSerializer(serializers.Serializer):
ping_id = serializers.IntegerField()
pong = RecursiveField('PongSerializer', required=False)
Expand Down Expand Up @@ -94,6 +99,29 @@ def test_node_serializer(self):
self.serialize(NodeSerializer, value)
self.deserialize(NodeSerializer, value)

def test_many_null_serializer(self):
"""Test that allow_null is propagated when many=True"""

# Children is omitted from the root node
value = {
'name': 'root'
}

self.serialize(ManyNullSerializer, value)
self.deserialize(ManyNullSerializer, value)

# Children is omitted from the child nodes
value2 = {
'name': 'root',
'children':[
{'name': 'child1'},
{'name': 'child2'},
]
}

self.serialize(ManyNullSerializer, value2)
self.deserialize(ManyNullSerializer, value2)

def test_ping_pong(self):
pong = {
'pong_id': 4,
Expand Down
10 changes: 5 additions & 5 deletions tox.ini
@@ -1,13 +1,13 @@
[tox]
envlist =
{py27,py33,py34}-django{1.6,1.7}-drf{3.0}
{py27,py33,py34}-django{1.8,1.9}-drf{3.3}

[testenv]
commands = ./runtests.py --fast
setenv =
PYTHONDONTWRITEBYTECODE=1
deps =
django1.6: Django==1.6.8
django1.7: Django==1.7.1
drf3.0: djangorestframework==3.0.4
pytest-django==2.6.1
django1.8: Django==1.8.7
django1.9: Django==1.9
drf3.3: djangorestframework==3.3
pytest-django==2.9.1

0 comments on commit 3821fd2

Please sign in to comment.