summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKane <omgsif@gmail.com>2014-11-30 09:37:05 (GMT)
committerKane <omgsif@gmail.com>2014-11-30 09:37:17 (GMT)
commit1594f8778421034de40c35e10e7ec109c295d53c (patch)
treece72fe93f917c26a9a9ab0f8944daec5aca26d1d
parenta271df7554fcb1cbe9dd76b9157f8cd201f332d8 (diff)
downloaddjango-import-export-1594f8778421034de40c35e10e7ec109c295d53c.zip
django-import-export-1594f8778421034de40c35e10e7ec109c295d53c.tar.gz
django-import-export-1594f8778421034de40c35e10e7ec109c295d53c.tar.bz2
Unit test for one to one field in a resource
-rw-r--r--tests/core/models.py1
-rw-r--r--tests/core/tests/resources_tests.py4
2 files changed, 4 insertions, 1 deletions
diff --git a/tests/core/models.py b/tests/core/models.py
index 4fe6d4a..1e07095 100644
--- a/tests/core/models.py
+++ b/tests/core/models.py
@@ -38,6 +38,7 @@ class Book(models.Model):
class Profile(models.Model):
user = models.OneToOneField('auth.User')
+ is_private = models.BooleanField(default=True)
class Entry(models.Model):
diff --git a/tests/core/tests/resources_tests.py b/tests/core/tests/resources_tests.py
index 4bb796c..b3901d5 100644
--- a/tests/core/tests/resources_tests.py
+++ b/tests/core/tests/resources_tests.py
@@ -347,12 +347,14 @@ class ModelResourceTest(TestCase):
class EntryResource(resources.ModelResource):
class Meta:
model = Entry
- fields = ('user__profile',)
+ fields = ('user__profile', 'user__profile__is_private')
resource = EntryResource()
dataset = resource.export(Entry.objects.all())
self.assertEqual(dataset.dict[0]['user__profile'], profile.pk)
+ self.assertEqual(dataset.dict[0]['user__profile__is_private'], '1')
self.assertEqual(dataset.dict[1]['user__profile'], '')
+ self.assertEqual(dataset.dict[1]['user__profile__is_private'], '')
def test_empty_get_queryset(self):
# issue #25 - Overriding queryset on export() fails when passed