Added tests for db.backends.utils.truncate_name().

This commit is contained in:
Mariusz Felisiak 2017-02-16 23:14:02 +01:00 committed by Tim Graham
parent d5088f838d
commit 1f7ca85866
1 changed files with 7 additions and 0 deletions

View File

@ -1,4 +1,5 @@
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
from django.db.backends.utils import truncate_name
from django.db.utils import load_backend from django.db.utils import load_backend
from django.test import SimpleTestCase from django.test import SimpleTestCase
@ -13,3 +14,9 @@ class TestLoadBackend(SimpleTestCase):
with self.assertRaisesMessage(ImproperlyConfigured, msg) as cm: with self.assertRaisesMessage(ImproperlyConfigured, msg) as cm:
load_backend('foo') load_backend('foo')
self.assertEqual(str(cm.exception.__cause__), "No module named 'foo'") self.assertEqual(str(cm.exception.__cause__), "No module named 'foo'")
def test_truncate_name(self):
self.assertEqual(truncate_name('some_table', 10), 'some_table')
self.assertEqual(truncate_name('some_long_table', 10), 'some_la38a')
self.assertEqual(truncate_name('some_long_table', 10, 3), 'some_loa38')
self.assertEqual(truncate_name('some_long_table'), 'some_long_table')