From a66f448f11c0c7a4e074dbc7a49b2a490d9101e0 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Thu, 16 Feb 2017 23:14:02 +0100 Subject: [PATCH] [1.11.x] Added tests for db.backends.utils.truncate_name(). Backport of 1f7ca858664491589ba400419a491dd0a9af5dff from master --- tests/backends/test_utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/backends/test_utils.py b/tests/backends/test_utils.py index 6f59d1b23b..ac7f9ab848 100644 --- a/tests/backends/test_utils.py +++ b/tests/backends/test_utils.py @@ -1,4 +1,5 @@ from django.core.exceptions import ImproperlyConfigured +from django.db.backends.utils import truncate_name from django.db.utils import load_backend from django.test import SimpleTestCase from django.utils import six @@ -14,3 +15,9 @@ class TestLoadBackend(SimpleTestCase): ) % "foo.base" if six.PY2 else "'foo'" with self.assertRaisesMessage(ImproperlyConfigured, msg): load_backend('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')