def test__get_address(self):
    self.patch_object(self.c, '_get_address_unit', name='mock__get_address_unit')
    self.mock__get_address_unit.return_value = '1.2.3.4'
    self.patch_object(self.c, '_get_address_machine', name='mock__get_address_machine')
    self.mock__get_address_machine.return_value = '5.6.7.8'
    self.c._juju_type = self.c.JujuTypes.UNIT
    self.assertEqual(self.c._get_address(None, 'cidr'), '1.2.3.4')
    self.mock__get_address_unit.assert_called_once_with('juju-info', 'cidr')
    self.mock__get_address_unit.reset_mock()
    self.c._juju_type = self.c.JujuTypes.MACHINE
    self.assertEqual(self.c._get_address(None, 'cidr'), '5.6.7.8')
    self.mock__get_address_machine.assert_called_once_with('cidr')
    self.c._juju_type = None
    with self.assertRaises(RuntimeError):
        self.c._get_address(None, 'cidr')
def test__get_address(self):
    self.patch_object(self.c, '_get_address_unit', name='mock__get_address_unit')
    self.mock__get_address_unit.return_value = '1.2.3.4'
    self.patch_object(self.c, '_get_address_machine', name='mock__get_address_machine')
    self.mock__get_address_machine.return_value = '5.6.7.8'
    self.c._juju_type = self.c.JujuTypes.UNIT
    self.assertEqual(self.c._get_address(None, 'cidr'), '1.2.3.4')
    self.mock__get_address_unit.assert_called_once_with('juju-info', 'cidr')
    self.mock__get_address_unit.reset_mock()
    self.c._juju_type = self.c.JujuTypes.MACHINE
    self.assertEqual(self.c._get_address(None, 'cidr'), '5.6.7.8')
    self.mock__get_address_machine.assert_called_once_with('cidr')
    self.c._juju_type = None
    with self.assertRaises(RuntimeError):
        self.c._get_address(None, 'cidr')