def test_make_dsn():
    """Test the Django DSN string builder."""

    # Setup django in the current thread; other tests just
    # used it via an external process.
    from django.core.management import setup_environ
    import proj.settings
    setup_environ(proj.settings)
    from feedplatform.integration.django.models import make_dsn

    # Automatically generate a list of all possible variations
    # of missing connection data. Test both with None and ''
    # values.
    base = ['michael', 'xyz123', 'localhost', '3600', 'foo']

    def yield_variants(value, collector, pos=0, blackout=None):
        collector.append(value)
        for i in range(pos, len(value)):
            v = copy.copy(value)
            v[i] = blackout
            yield_variants(v, collector, i+1, blackout)

    variants_to_test = []
    yield_variants(base, variants_to_test, blackout=None)
    yield_variants(base, variants_to_test, blackout='')

    # Check that the decoded version of what we encode matches the
    # original, for all possible variations.
    for user, password, host, port, database in variants_to_test:
        obj = type('FakeSettings', (), {})()
        obj.DATABASE_ENGINE = 'mysql'
        obj.DATABASE_USER = user
        obj.DATABASE_PASSWORD = password
        obj.DATABASE_HOST = host
        obj.DATABASE_PORT = port
        obj.DATABASE_NAME = database
        uri = URI(make_dsn(obj))

        for a, b in zip(
            (uri.username, uri.password, uri.host, uri.port, uri.database),
            (user, password, host, port, database)
        ):
            assert str(a) == str(b) or (a in (None, '') and b in (None, ''))
from feedplatform.lib import *
from feedplatform.integration.django.models import make_dsn

DATABASE = make_dsn()

from Queue import Queue
queue = Queue(0)

ADDINS = [
    provide_loop_daemon(name="loop"),
    provide_multi_daemon(daemons=[
	provide_queue_daemon(queue),
	provide_socket_queue_controller(queue, ('localhost', 7777))
    ], name="queue"),
    collect_feed_data('title', 'updated', 'summary', 'language'),
]