-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,8 @@ | |
from django_hstore import hstore | ||
from django_hstore.virtual import create_hstore_virtual_field | ||
|
||
from django_hstore_tests.models import SchemaDataBag, NullSchemaDataBag | ||
from django_hstore_tests.models import (CustomType, SchemaDataBag, | ||
NullSchemaDataBag) | ||
|
||
|
||
MIGRATION_PATH = '{0}/../{1}'.format(os.path.dirname(__file__), 'migrations') | ||
|
@@ -65,6 +66,15 @@ def test_dict_get(self): | |
self.assertEqual(d.get('default_test', 'default'), 'default') | ||
self.assertIsNone(d.get('default_test')) | ||
|
||
def test_save_custom_type(self): | ||
d = SchemaDataBag() | ||
v = CustomType('some value') | ||
d.custom = v | ||
d.save() | ||
d = SchemaDataBag.objects.get(pk=d.id) | ||
self.assertEqual(dict.get(d.data, 'custom'), '[some value]') | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ktosiek
via email
Author
|
||
self.assertEqual(d.custom, v) | ||
|
||
def test_virtual_field_default_value(self): | ||
d = SchemaDataBag() | ||
self.assertEqual(d.number, 0) | ||
|
I don't know if this line should stay, but the error it generates shows my current problem rather nicely -
v
is serialized as"<django_hstore_tests.models.CustomType object at 0x...>"
instead of"[some value]"
.