Esempio n. 1
0
    def test_provided_capabilities(self):
        ctx = {
            'node_id': '5678',
        }

        rest_client_mock.put_node_instance('5678',
                                           relationships=[{
                                               'target_id':
                                               'some_node',
                                               'target_name':
                                               'some_node'
                                           }])
        rest_client_mock.put_node_instance('some_node',
                                           runtime_properties={'k': 'v'})

        kwargs = {'__cloudify_context': ctx}
        ctx = acquire_context(0, 0, **kwargs)
        with warnings.catch_warnings(record=True) as warns:
            self.assertIn('k', ctx.capabilities)
            self.assertEquals('v', ctx.capabilities['k'])
        if sys.version_info < (2, 7):
            # i was unable to make this work on py2.6
            return
        self.assertEqual(len(warns), 2)
        for w in warns:
            self.assertIn('capabilities is deprecated', str(w))
    def test_provided_capabilities(self):
        ctx = {
            'node_id': '5678',
        }

        # using a mock rest client
        manager.get_rest_client = \
            lambda: rest_client_mock.MockRestclient()

        rest_client_mock.put_node_instance(
            '5678',
            relationships=[{'target_id': 'some_node',
                            'target_name': 'some_node'}])
        rest_client_mock.put_node_instance('some_node',
                                           runtime_properties={'k': 'v'})

        kwargs = {'__cloudify_context': ctx}
        ctx = acquire_context(0, 0, **kwargs)
        self.assertIn('k', ctx.capabilities)
        self.assertEquals('v', ctx.capabilities['k'])
    def test_provided_capabilities(self):
        ctx = {
            'node_id': '5678',
        }

        # using a mock rest client
        manager.get_rest_client = \
            lambda: rest_client_mock.MockRestclient()

        rest_client_mock.put_node_instance(
            '5678',
            relationships=[{'target_id': 'some_node',
                            'target_name': 'some_node'}])
        rest_client_mock.put_node_instance('some_node',
                                           runtime_properties={'k': 'v'})

        kwargs = {'__cloudify_context': ctx}
        ctx = acquire_context(0, 0, **kwargs)
        self.assertIn('k', ctx.capabilities)
        self.assertEquals('v', ctx.capabilities['k'])
Esempio n. 4
0
    def test_capabilities_clash(self):
        ctx = {
            'node_id': '5678',
        }

        rest_client_mock.put_node_instance('5678',
                                           relationships=[{
                                               'target_id':
                                               'node1',
                                               'target_name':
                                               'node1'
                                           }, {
                                               'target_id':
                                               'node2',
                                               'target_name':
                                               'node2'
                                           }])

        rest_client_mock.put_node_instance('node1',
                                           runtime_properties={'k': 'v1'})
        rest_client_mock.put_node_instance('node2',
                                           runtime_properties={'k': 'v2'})

        kwargs = {'__cloudify_context': ctx}
        ctx = acquire_context(0, 0, **kwargs)
        with warnings.catch_warnings(record=True) as warns:
            self.assertRaises(NonRecoverableError,
                              lambda: 'k' in ctx.capabilities)
        if sys.version_info < (2, 7):
            # i was unable to make this work on py2.6
            return
        self.assertEqual(len(warns), 1)
        self.assertIn('capabilities is deprecated', str(warns[0]))
    def test_capabilities_clash(self):
        ctx = {
            'node_id': '5678',
        }

        # using a mock rest client
        manager.get_rest_client = \
            lambda: rest_client_mock.MockRestclient()

        rest_client_mock.put_node_instance('5678',
                                           relationships=[{
                                               'target_id':
                                               'node1',
                                               'target_name':
                                               'node1'
                                           }, {
                                               'target_id':
                                               'node2',
                                               'target_name':
                                               'node2'
                                           }])

        rest_client_mock.put_node_instance('node1',
                                           runtime_properties={'k': 'v1'})
        rest_client_mock.put_node_instance('node2',
                                           runtime_properties={'k': 'v2'})

        kwargs = {'__cloudify_context': ctx}
        ctx = acquire_context(0, 0, **kwargs)
        self.assertRaises(NonRecoverableError, ctx.capabilities.__contains__,
                          'k')
    def test_capabilities_clash(self):
        ctx = {
            'node_id': '5678',
        }

        # using a mock rest client
        manager.get_rest_client = \
            lambda: rest_client_mock.MockRestclient()

        rest_client_mock.put_node_instance(
            '5678',
            relationships=[{'target_id': 'node1',
                            'target_name': 'node1'},
                           {'target_id': 'node2',
                            'target_name': 'node2'}])

        rest_client_mock.put_node_instance('node1',
                                           runtime_properties={'k': 'v1'})
        rest_client_mock.put_node_instance('node2',
                                           runtime_properties={'k': 'v2'})

        kwargs = {'__cloudify_context': ctx}
        ctx = acquire_context(0, 0, **kwargs)
        self.assertRaises(NonRecoverableError, ctx.capabilities.__contains__,
                          'k')