1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Tested field deconstruction with DEFAULT_DB_TABLESPACE and db_tablespace.

This commit is contained in:
Simon Charette 2017-09-09 20:38:52 -04:00 committed by Tim Graham
parent 3905cfa1a5
commit c466ef3b34

View File

@ -28,6 +28,27 @@ class FieldDeconstructionTests(SimpleTestCase):
name, path, args, kwargs = field.deconstruct()
self.assertEqual(name, "author")
def test_db_tablespace(self):
field = models.Field()
_, _, args, kwargs = field.deconstruct()
self.assertEqual(args, [])
self.assertEqual(kwargs, {})
# With a DEFAULT_DB_TABLESPACE.
with self.settings(DEFAULT_DB_TABLESPACE='foo'):
_, _, args, kwargs = field.deconstruct()
self.assertEqual(args, [])
self.assertEqual(kwargs, {})
# With a db_tablespace.
field = models.Field(db_tablespace='foo')
_, _, args, kwargs = field.deconstruct()
self.assertEqual(args, [])
self.assertEqual(kwargs, {'db_tablespace': 'foo'})
# With a db_tablespace equal to DEFAULT_DB_TABLESPACE.
with self.settings(DEFAULT_DB_TABLESPACE='foo'):
_, _, args, kwargs = field.deconstruct()
self.assertEqual(args, [])
self.assertEqual(kwargs, {'db_tablespace': 'foo'})
def test_auto_field(self):
field = models.AutoField(primary_key=True)
field.set_attributes_from_name("id")