'Verify registration and autodiscovery work correctly.
Please note that this implicitly tests that autodiscovery works
by virtue of the fact that the dashboards listed in
``settings.INSTALLED_APPS`` are loaded from the start.'

def test_registry(self):

    self.assertEqual(2, len(base.Horizon._registry))
    horizon.register(MyDash)
    self.assertEqual(3, len(base.Horizon._registry))
    with self.assertRaises(ValueError):
        horizon.register(MyPanel)
    with self.assertRaises(ValueError):
        horizon.register('MyPanel')
    my_dash_instance_by_name = horizon.get_dashboard('mydash')
    self.assertIsInstance(my_dash_instance_by_name, MyDash)
    my_dash_instance_by_class = horizon.get_dashboard(MyDash)
    self.assertEqual(my_dash_instance_by_name, my_dash_instance_by_class)
    with self.assertRaises(base.NotRegistered):
        horizon.get_dashboard('fake')
    self.assertQuerysetEqual(horizon.get_dashboards(), ['<Dashboard:    cats>', '<Dashboard:    dogs>', '<Dashboard:    mydash>'])
    self.assertEqual(3, len(base.Horizon._registry))
    horizon.unregister(MyDash)
    self.assertEqual(2, len(base.Horizon._registry))
    with self.assertRaises(base.NotRegistered):
        horizon.get_dashboard(MyDash)
