コード例 #1
0
ファイル: test.py プロジェクト: Fewbytes/cloudify-chef-plugin
 def _run(self, a1key, has_default, has_rel, has_prop_key,
          has_chef_attr_key, expect_exception=None):
     merge_chef_attributes = {
         'attr1': {
         }
     }
     merge_chef_attributes['attr1'][a1key] = 'prop1'
     if has_default:
         merge_chef_attributes['attr1'][
             'default_value'] = 'attr1_default_val'
     if has_rel:
         runtime_properties = {}
         if has_prop_key:
             runtime_properties['prop1'] = 'prop_val'
         if has_chef_attr_key:
             runtime_properties['chef_attributes'] = {
                 'prop1': 'chef_attr_val'
             }
         related = MockCloudifyContext(
             node_id='clodufiy_db_node_id_' + str(node_id.next()),
             runtime_properties=runtime_properties,
         )
     else:
         related = None
     # print("MERGE_CHEF_ATTRIBUTES", merge_chef_attributes)
     ctx = _make_context(
         operation='install', merge_chef_attributes=merge_chef_attributes,
         related=related)
     # print("CTX", str(ctx), "RELATED", str(related))
     if expect_exception:
         self.assertRaises(
             expect_exception, chef_client._prepare_chef_attributes, ctx)
     else:
         return chef_client._prepare_chef_attributes(ctx)
コード例 #2
0
ファイル: test.py プロジェクト: shayn1234/Clearwater-new
 def test_deep(self):
     target = mocks.MockContext({
         'node':
         mocks.MockContext({'properties': {}}),
         'instance':
         mocks.MockContext({
             'id':
             'clodufiy_db_node_id_' + str(node_id.next()),
             'runtime_properties': {
                 'chef_attributes': {
                     'a': {
                         'b': 7
                     }
                 }
             }
         })
     })
     ctx = _make_context(operation='install',
                         merge_chef_attributes={
                             'attr2': {
                                 'attr2b': {
                                     'related_chef_attribute': 'a.b'
                                 }
                             }
                         },
                         target=target)
     # print("CTX", str(ctx), "RELATED", str(related))
     v = chef_client._prepare_chef_attributes(ctx)
     self.assertIn('attr2', v)
     self.assertIn('attr2b', v['attr2'])
     self.assertEquals(v['attr2']['attr2b'], 7)
コード例 #3
0
    def test_deep(self):
        target = mocks.MockContext({
            'node': mocks.MockContext({
                'properties': {}
            }),
            'instance': mocks.MockContext({
                'id': 'clodufiy_db_node_id_' + str(node_id.next()),
                'runtime_properties': {
                    'chef_attributes': {
                        'a': {
                            'b': 7
                        }
                    }
                }
            })
        })
        ctx = _make_context(operation='install', merge_chef_attributes={
            'attr2': {
                'attr2b': {
                    'related_chef_attribute': 'a.b'
                }
            }

        }, target=target)
        # print("CTX", str(ctx), "RELATED", str(related))
        v = chef_client._prepare_chef_attributes(ctx)
        self.assertIn('attr2', v)
        self.assertIn('attr2b', v['attr2'])
        self.assertEquals(v['attr2']['attr2b'], 7)
コード例 #4
0
ファイル: test.py プロジェクト: shayn1234/Clearwater-new
 def _run(self,
          a1key,
          has_default,
          has_rel,
          has_prop_key,
          has_chef_attr_key,
          expect_exception=None):
     merge_chef_attributes = {'attr1': {}}
     merge_chef_attributes['attr1'][a1key] = 'prop1'
     if has_default:
         merge_chef_attributes['attr1'][
             'default_value'] = 'attr1_default_val'
     if has_rel:
         runtime_properties = {}
         if has_prop_key:
             runtime_properties['prop1'] = 'prop_val'
         if has_chef_attr_key:
             runtime_properties['chef_attributes'] = {
                 'prop1': 'chef_attr_val'
             }
         target = mocks.MockContext({
             'node':
             mocks.MockContext({'properties': {}}),
             'instance':
             mocks.MockContext({
                 'id':
                 'clodufiy_db_node_id_' + str(node_id.next()),
                 'runtime_properties':
                 runtime_properties
             })
         })
     else:
         target = None
     # print("MERGE_CHEF_ATTRIBUTES", merge_chef_attributes)
     ctx = _make_context(operation='install',
                         merge_chef_attributes=merge_chef_attributes,
                         target=target)
     # print("CTX", str(ctx), "RELATED", str(related))
     if expect_exception:
         self.assertRaises(expect_exception,
                           chef_client._prepare_chef_attributes, ctx)
     else:
         return chef_client._prepare_chef_attributes(ctx)
コード例 #5
0
 def test_deep(self):
     related = MockCloudifyContext(
         node_id='clodufiy_db_node_id_' + str(node_id.next()),
         runtime_properties={'chef_attributes': {
             'a': {
                 'b': 7
             }
         }},
     )
     ctx = _make_context(operation='install',
                         merge_chef_attributes={
                             'attr2': {
                                 'attr2b': {
                                     'related_chef_attribute': 'a.b'
                                 }
                             }
                         },
                         related=related)
     # print("CTX", str(ctx), "RELATED", str(related))
     v = chef_client._prepare_chef_attributes(ctx)
     self.assertIn('attr2', v)
     self.assertIn('attr2b', v['attr2'])
     self.assertEquals(v['attr2']['attr2b'], 7)
コード例 #6
0
ファイル: test.py プロジェクト: Fewbytes/cloudify-chef-plugin
    def test_deep(self):
        related = MockCloudifyContext(
            node_id='clodufiy_db_node_id_' + str(node_id.next()),
            runtime_properties={
                'chef_attributes': {
                    'a': {
                        'b': 7
                    }
                }
            },
        )
        ctx = _make_context(operation='install', merge_chef_attributes={
            'attr2': {
                'attr2b': {
                    'related_chef_attribute': 'a.b'
                }
            }

        }, related=related)
        # print("CTX", str(ctx), "RELATED", str(related))
        v = chef_client._prepare_chef_attributes(ctx)
        self.assertIn('attr2', v)
        self.assertIn('attr2b', v['attr2'])
        self.assertEquals(v['attr2']['attr2b'], 7)