Skip to content

Commit

Permalink
update versions
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed Aug 23, 2016
1 parent 30736b4 commit 8fa8e19
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
11 changes: 7 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
language: python
sudo: false
python:
- "2.7"
- "3.4"
- "3.5"
env:
global:
- DRF="djangorestframework==3.3.2"
- DJANGO="django==1.9.3"
- DRF="djangorestframework==3.4.5"
matrix:
- LINT=
- LINT=1
- DJANGO="django==1.8.14"
- DJANGO="django==1.9.9"
- DJANGO="django==1.10"
- DJANGO="django==1.10" LINT=1
install:
- pip install $DJANGO
- pip install $DRF
Expand Down
2 changes: 1 addition & 1 deletion natural_keys/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def get_natural_key_info(cls):
fields = cls.get_natural_key_def()
info = []
for name in fields:
field = cls._meta.get_field_by_name(name)[0]
field = cls._meta.get_field(name)
rel_to = field.rel.to if field.rel else None
info.append((name, rel_to))
return info
Expand Down
Empty file added tests/test_app/__init__.py
Empty file.
17 changes: 11 additions & 6 deletions tests/test_naturalkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,22 @@ def test_naturalkey_duplicate(self):
class NaturalKeyRestTestCase(APITestCase):
def test_naturalkey_rest_serializer(self):
# Serializer should include validator
serializer = NaturalKeySerializer.for_model(NaturalKeyChild)
serializer = NaturalKeySerializer.for_model(NaturalKeyChild)()
self.maxDiff = 10000000
expect = """
Serializer():
parent = Serializer(required=True):
code = CharField(max_length=10, required=True)
group = CharField(max_length=10, required=True)
mode = CharField(max_length=10, required=True)
parent = Serializer():
code = CharField(max_length=10)
group = CharField(max_length=10)
mode = CharField(max_length=10)
class Meta:
validators = [<NaturalKeyValidator(queryset=NaturalKeyChild.objects.all(), fields=('parent', 'mode'))>]""".replace(" ", "")[1:] # noqa
self.assertEqual(str(serializer()), expect)
self.assertEqual(expect, str(serializer))

fields = serializer.get_fields()
self.assertTrue(fields['parent'].required)
self.assertTrue(fields['mode'].required)
self.assertTrue(fields['parent'].get_fields()['code'].required)

def test_naturalkey_rest_post(self):
# Posting a natural key should work
Expand Down
7 changes: 3 additions & 4 deletions tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from django.conf.urls import patterns, url, include
from django.conf.urls import url, include


urlpatterns = patterns(
'',
urlpatterns = [
url('', include('tests.test_app.urls')),
)
]

0 comments on commit 8fa8e19

Please sign in to comment.