我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用charmhelpers.core.hookenv.execution_environment()。
def test_gets_execution_environment(self, os_, relations_get, relations, relation_id, local_unit, relation_type, config): config.return_value = 'some-config' relation_type.return_value = 'some-type' local_unit.return_value = 'some-unit' relation_id.return_value = 'some-id' relations.return_value = 'all-relations' relations_get.return_value = 'some-relations' os_.environ = 'some-environment' result = hookenv.execution_environment() self.assertEqual(result, { 'conf': 'some-config', 'reltype': 'some-type', 'unit': 'some-unit', 'relid': 'some-id', 'rel': 'some-relations', 'rels': 'all-relations', 'env': 'some-environment', })
def test_gets_execution_environment_no_relation( self, os_, relations_get, relations, relation_id, local_unit, relation_type, config): config.return_value = 'some-config' relation_type.return_value = 'some-type' local_unit.return_value = 'some-unit' relation_id.return_value = None relations.return_value = 'all-relations' relations_get.return_value = 'some-relations' os_.environ = 'some-environment' result = hookenv.execution_environment() self.assertEqual(result, { 'conf': 'some-config', 'unit': 'some-unit', 'rels': 'all-relations', 'env': 'some-environment', })
def _record_hook(self, hookenv): data = hookenv.execution_environment() self.conf = conf_delta = self.kv.delta(data['conf'], 'config') self.rels = rels_delta = self.kv.delta(data['rels'], 'rels') self.kv.set('env', dict(data['env'])) self.kv.set('unit', data['unit']) self.kv.set('relid', data.get('relid')) return conf_delta, rels_delta