460
460
'ceph: Formatting block device %s as '
461
461
'filesystem %s.' % (device, fstype), level='INFO'
464
@patch.object(ceph_utils, 'relation_ids')
465
@patch.object(ceph_utils, 'related_units')
466
@patch.object(ceph_utils, 'relation_get')
467
def test_ensure_ceph_keyring_no_relation_no_data(self, rget, runits, rids):
468
rids.return_value = []
469
self.assertEquals(False, ceph_utils.ensure_ceph_keyring(service='foo'))
470
rids.return_value = ['ceph:0']
471
runits.return_value = ['ceph/0']
472
rget.return_value = ''
473
self.assertEquals(False, ceph_utils.ensure_ceph_keyring(service='foo'))
475
@patch.object(ceph_utils, '_keyring_path')
476
@patch.object(ceph_utils, 'create_keyring')
477
@patch.object(ceph_utils, 'relation_ids')
478
@patch.object(ceph_utils, 'related_units')
479
@patch.object(ceph_utils, 'relation_get')
480
def test_ensure_ceph_keyring_with_data(self, rget, runits,
481
rids, create, _path):
482
rids.return_value = ['ceph:0']
483
runits.return_value = ['ceph/0']
484
rget.return_value = 'fookey'
485
self.assertEquals(True,
486
ceph_utils.ensure_ceph_keyring(service='foo'))
487
create.assert_called_with(service='foo', key='fookey')
488
_path.assert_called_with('foo')
489
self.assertFalse(self.check_call.called)
491
_path.return_value = '/etc/ceph/client.foo.keyring'
494
ceph_utils.ensure_ceph_keyring(
495
service='foo', user='adam', group='users'))
496
create.assert_called_with(service='foo', key='fookey')
497
_path.assert_called_with('foo')
498
self.check_call.assert_called_with([
501
'/etc/ceph/client.foo.keyring'