diff options
| author | priyanshsaxena <geniuspriyansh@gmail.com> | 2018-01-18 23:45:16 +0530 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-04-27 21:37:42 -0400 |
| commit | 6b3d2920438746d260f7d158a91db53450055ae2 (patch) | |
| tree | d38a35b9793763e06e48394d5421828b20d2ed95 /tests | |
| parent | 6d1f5769455ad8e1384087b92aa5839c3540d9ba (diff) | |
Fixed #29015 -- Added an exception if the PostgreSQL database name is too long.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/backends/postgresql/tests.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/backends/postgresql/tests.py b/tests/backends/postgresql/tests.py index 43bd28eae9..33047df83b 100644 --- a/tests/backends/postgresql/tests.py +++ b/tests/backends/postgresql/tests.py @@ -2,6 +2,7 @@ import unittest import warnings from unittest import mock +from django.core.exceptions import ImproperlyConfigured from django.db import DatabaseError, connection, connections from django.test import TestCase @@ -39,6 +40,18 @@ class Tests(TestCase): self.assertEqual(len(w), 1) self.assertEqual(w[0].message.__class__, RuntimeWarning) + def test_database_name_too_long(self): + from django.db.backends.postgresql.base import DatabaseWrapper + settings = connection.settings_dict.copy() + max_name_length = connection.ops.max_name_length() + settings['NAME'] = 'a' + (max_name_length * 'a') + msg = ( + 'Database names longer than %d characters are not supported by ' + 'PostgreSQL. Supply a shorter NAME in settings.DATABASES.' + ) % max_name_length + with self.assertRaisesMessage(ImproperlyConfigured, msg): + DatabaseWrapper(settings).get_connection_params() + def test_connect_and_rollback(self): """ PostgreSQL shouldn't roll back SET TIME ZONE, even if the first |
