Exemplo n.º 1
0
 def test_sqlite_basic(self):
     res = expand_db_url('sqlite:///tmp/test.sqlite')
     self.assertEqual(res, {
         'client': SqliteClient,
         'params': {
             'filename': '/tmp/test.sqlite',  # nosec
         }
     })
Exemplo n.º 2
0
 def test_sqlite_params(self):
     res = expand_db_url('sqlite:///tmp/test.sqlite?AHA=5&moo=yes')
     self.assertEqual(res, {
         'client': SqliteClient,
         'params': {
             'filename': '/tmp/test.sqlite',  # nosec
             'AHA': '5',
             'moo': 'yes',
         }
     })
Exemplo n.º 3
0
 def test_postgres_basic(self):
     res = expand_db_url('postgres://postgres:@127.0.0.1:5432/test')
     self.assertEqual(res, {
         'client': AsyncpgDBClient,
         'params': {
             'database': 'test',
             'host': '127.0.0.1',
             'password': '',
             'port': '5432',
             'user': '******',
         }
     })
Exemplo n.º 4
0
 def test_sqlite_testing(self):
     res = expand_db_url('sqlite:///tmp/test-{}.sqlite', testing=True)
     self.assertIn('/tmp/test-', res['params']['filename'])  # nosec
     self.assertIn('.sqlite', res['params']['filename'])
     self.assertNotEqual('sqlite:///tmp/test-{}.sqlite', res['params']['filename'])
     self.assertEqual(res, {
         'client': SqliteClient,
         'params': {
             'filename': res['params']['filename'],
             'single_connection': True,
         }
     })
Exemplo n.º 5
0
 def test_mysql_basic(self):
     res = expand_db_url('mysql://root:@127.0.0.1:3306/test')
     self.assertEqual(
         res, {
             'client': MySQLClient,
             'params': {
                 'database': 'test',
                 'host': '127.0.0.1',
                 'password': '',
                 'port': '3306',
                 'user': '******',
             }
         })
Exemplo n.º 6
0
 def test_mysql_params(self):
     res = expand_db_url('mysql://root:@127.0.0.1:3306/test?AHA=5&moo=yes')
     self.assertEqual(
         res, {
             'client': MySQLClient,
             'params': {
                 'database': 'test',
                 'host': '127.0.0.1',
                 'password': '',
                 'port': '3306',
                 'user': '******',
                 'AHA': '5',
                 'moo': 'yes',
             }
         })
Exemplo n.º 7
0
 def test_postgres_testing(self):
     res = expand_db_url('postgres://postgres:@127.0.0.1:5432/test_\{\}', testing=True)
     self.assertIn('test_', res['params']['database'])
     self.assertNotEqual('test_{}', res['params']['database'])
     self.assertEqual(res, {
         'client': AsyncpgDBClient,
         'params': {
             'database': res['params']['database'],
             'host': '127.0.0.1',
             'password': '',
             'port': '5432',
             'user': '******',
             'single_connection': True,
         }
     })
Exemplo n.º 8
0
 def test_mysql_testing(self):
     res = expand_db_url('mysql://root:@127.0.0.1:3306/test_\{\}',
                         testing=True)
     self.assertIn('test_', res['params']['database'])
     self.assertNotEqual('test_{}', res['params']['database'])
     self.assertEqual(
         res, {
             'client': MySQLClient,
             'params': {
                 'database': res['params']['database'],
                 'host': '127.0.0.1',
                 'password': '',
                 'port': '3306',
                 'user': '******',
                 'single_connection': True,
             }
         })
Exemplo n.º 9
0
 def test_unknown_scheme(self):
     with self.assertRaises(ConfigurationError):
         expand_db_url('moo://baa')
Exemplo n.º 10
0
 def test_postgres_nonint_port(self):
     with self.assertRaises(ConfigurationError):
         expand_db_url('postgres://postgres:@127.0.0.1:moo/test')
Exemplo n.º 11
0
 def test_sqlite_invalid(self):
     with self.assertRaises(ConfigurationError):
         expand_db_url('sqlite://')
Exemplo n.º 12
0
 def test_mysql_nonint_port(self):
     with self.assertRaises(ConfigurationError):
         expand_db_url('mysql://root:@127.0.0.1:moo/test')