def test_make_instance_with(self):
    mock_handler = mock.Mock()
    mock_handler.return_value = 'an-instance'
    self.patch_object(conncheck.ConnCheckManager, '_spec_handlers', name='mock_cls__spec_handlers', new={})
    conncheck.ConnCheckManager.register_spec_handler('juju', mock_handler)
    with self.assertRaises(ValueError):
        self.c.make_instance_with('i')
    with self.assertRaises(KeyError):
        self.c.make_instance_with('some:thing')
    self.assertEqual(self.c.make_instance_with('juju:0', this='that', some='thing'), 'an-instance')
    mock_handler.assert_called_once_with('0', this='that', some='thing')
def test_make_instance_with(self):
    mock_handler = mock.Mock()
    mock_handler.return_value = 'an-instance'
    self.patch_object(conncheck.ConnCheckManager, '_spec_handlers', name='mock_cls__spec_handlers', new={})
    conncheck.ConnCheckManager.register_spec_handler('juju', mock_handler)
    with self.assertRaises(ValueError):
        self.c.make_instance_with('i')
    with self.assertRaises(KeyError):
        self.c.make_instance_with('some:thing')
    self.assertEqual(self.c.make_instance_with('juju:0', this='that', some='thing'), 'an-instance')
    mock_handler.assert_called_once_with('0', this='that', some='thing')