blob: 13099292cac9bd119db4c4d68d73c64f1b1b1878 [file] [log] [blame]
dfilppi9981f552017-08-07 20:10:53 +00001import json
2import os
3
4from cloudify.context import BootstrapContext
5
6from cloudify.mocks import MockCloudifyContext
7
8
9RETRY_AFTER = 1
10# Time during which no retry could possibly happen.
11NO_POSSIBLE_RETRY_TIME = RETRY_AFTER / 2.0
12
13BOOTSTRAP_CONTEXTS_WITHOUT_PREFIX = (
14 {
15 },
16 {
17 'resources_prefix': ''
18 },
19 {
20 'resources_prefix': None
21 },
22)
23
24
25def set_mock_provider_context(ctx, provider_context):
26
27 def mock_provider_context(provider_name_unused):
28 return provider_context
29
30 ctx.get_provider_context = mock_provider_context
31
32
33def create_mock_ctx_with_provider_info(*args, **kw):
34 cur_dir = os.path.dirname(os.path.realpath(__file__))
35 full_file_name = os.path.join(cur_dir, 'provider-context.json')
36 with open(full_file_name) as f:
37 provider_context = json.loads(f.read())['context']
38 kw['provider_context'] = provider_context
39 kw['bootstrap_context'] = BootstrapContext(provider_context['cloudify'])
40 return MockCloudifyContext(*args, **kw)