check dicts output of parse_database_connection_string() in tests, part of #72

This commit is contained in:
meeb 2021-04-04 23:04:51 +10:00
parent 20df9f4044
commit 5461a5357d
1 changed files with 22 additions and 0 deletions

View File

@ -70,8 +70,30 @@ class DatabaseConnectionTestCase(TestCase):
def test_parse_database_connection_string(self): def test_parse_database_connection_string(self):
database_dict = parse_database_connection_string( database_dict = parse_database_connection_string(
'postgresql://tubesync:password@localhost:5432/tubesync') 'postgresql://tubesync:password@localhost:5432/tubesync')
self.assertEqual(database_dict,
{
'DRIVER': 'postgresql',
'ENGINE': 'django.db.backends.postgresql',
'USER': 'tubesync',
'PASSWORD': 'password',
'HOST': 'localhost',
'PORT': 5432,
'NAME': 'tubesync',
}
)
database_dict = parse_database_connection_string( database_dict = parse_database_connection_string(
'mysql://tubesync:password@localhost:3306/tubesync') 'mysql://tubesync:password@localhost:3306/tubesync')
self.assertEqual(database_dict,
{
'DRIVER': 'mysql',
'ENGINE': 'django.db.backends.mysql',
'USER': 'tubesync',
'PASSWORD': 'password',
'HOST': 'localhost',
'PORT': 3306,
'NAME': 'tubesync',
}
)
# Invalid driver # Invalid driver
with self.assertRaises(DatabaseConnectionError): with self.assertRaises(DatabaseConnectionError):
parse_database_connection_string( parse_database_connection_string(