def test_add_instance(self):
    self.patch_object(self.c, 'make_instance_with', name='mock_make_instance_with')
    self.mock_make_instance_with.return_value = 'an-instance'
    self.c.add_instance('juju:0', this='that', some='thing')
    self.mock_make_instance_with.assert_called_once_with('juju:0', this='that', some='thing', module_source='conncheck', collection='a-collection')
    self.assertIn('juju:0', self.c._instances)
    self.assertEqual(self.c._instances['juju:0'], 'an-instance')
    with self.assertRaises(RuntimeError):
        self.c.add_instance('juju:0', this='that', some='thing')
def test_add_instance(self):
    self.patch_object(self.c, 'make_instance_with', name='mock_make_instance_with')
    self.mock_make_instance_with.return_value = 'an-instance'
    self.c.add_instance('juju:0', this='that', some='thing')
    self.mock_make_instance_with.assert_called_once_with('juju:0', this='that', some='thing', module_source='conncheck', collection='a-collection')
    self.assertIn('juju:0', self.c._instances)
    self.assertEqual(self.c._instances['juju:0'], 'an-instance')
    with self.assertRaises(RuntimeError):
        self.c.add_instance('juju:0', this='that', some='thing')