# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.test import TestCase

from channels.backends.base import BaseChannel
from channels.exceptions import ImproperlyConfigured


class TestChannel(BaseChannel):
    def send(self, message):
        pass


class BaseChannelTestCase(TestCase):
    def test_init(self):
        with self.assertRaises(TypeError):
            BaseChannel()

    def test_load_required_config(self):
        channel = TestChannel()
        config = {
            "URL": "http://example.com",
            "USERNAME": "testuser"
        }
        channel.load_required_config(config, {
            "URL": "url"
        })
        self.assertEqual(channel.url, config["URL"])

        with self.assertRaises(ImproperlyConfigured):
            channel.load_required_config({}, {
                "URL": "url",
                "USERNAME": "username"
            })

@@ -894,16 +894,436 @@
 %0A            %7D)%0A
+%0A    def test_load_optional_config(self):%0A        channel = TestChannel()%0A        config = %7B%0A            %22URL%22: %22http://example.com%22,%0A            %22USERNAME%22: %22testuser%22%0A        %7D%0A        channel.load_optional_config(config, %7B%0A            %22USERNAME%22: %22username%22,%0A            %22CHANNEL%22: %22channel%22%0A        %7D)%0A        self.assertEqual(channel.username, config%5B%22USERNAME%22%5D)%0A        self.assertFalse(hasattr(self, %22channel%22))%0A

Add test_load_required_config