from peewee import *
from playhouse.db_url import connect
from playhouse.sqlite_ext import SqliteExtDatabase
from playhouse.tests.base import PeeweeTestCase


class TestDBURL(PeeweeTestCase):
    def test_db_url(self):
        db = connect('sqlite:///:memory:')
        self.assertTrue(isinstance(db, SqliteDatabase))
        self.assertEqual(db.database, ':memory:')

        db = connect('sqliteext:///foo/bar.db')
        self.assertTrue(isinstance(db, SqliteExtDatabase))
        self.assertEqual(db.database, 'foo/bar.db')

        db = connect('sqlite:////this/is/absolute.path')
        self.assertEqual(db.database, '/this/is/absolute.path')

        db = connect('sqlite://')
        self.assertTrue(isinstance(db, SqliteDatabase))
        self.assertEqual(db.database, ':memory:')

    def test_bad_scheme(self):
        def _test_scheme():
            connect('missing:///')

        self.assertRaises(RuntimeError, _test_scheme)

@@ -50,16 +50,23 @@
  connect
+, parse
 %0Afrom pl
@@ -192,16 +192,428 @@
 tCase):%0A
+    def test_db_url_parse(self):%0A        cfg = parse('mysql://usr:pwd@hst:123/db')%0A        self.assertEqual(cfg%5B'user'%5D, 'usr')%0A        self.assertEqual(cfg%5B'passwd'%5D, 'pwd')%0A        self.assertEqual(cfg%5B'host'%5D, 'hst')%0A        self.assertEqual(cfg%5B'database'%5D, 'db')%0A        self.assertEqual(cfg%5B'port'%5D, 123)%0A        cfg = parse('postgresql://usr:pwd@hst/db')%0A        self.assertEqual(cfg%5B'password'%5D, 'pwd')%0A%0A
     def 

Test for db_url.parse