def test_gets_the_relation_id(self, os_, relation_ids, remote_service_name):
os_.environ = {
'JUJU_RELATION_ID': 'foo',
}
self.assertEqual(hookenv.relation_id(), 'foo')
relation_ids.return_value = ['r:1', 'r:2']
remote_service_name.side_effect = ['other', 'service']
self.assertEqual(hookenv.relation_id('rel', 'service/0'), 'r:2')
relation_ids.assert_called_once_with('rel')
self.assertEqual(remote_service_name.call_args_list, [
call('r:1'),
call('r:2'),
])
remote_service_name.side_effect = ['other', 'service']
self.assertEqual(hookenv.relation_id('rel', 'service'), 'r:2')
评论列表
文章目录