Example #1
0
    def test_prepare_assoc_Role(self):
        _source_ctx, _target_ctx, _ctx = self._create_common_relationships(
            'test_prepare_assoc',
            source_type_hierarchy=INSTANCE_READ_REPLICA_TH,
            target_type_hierarchy=[
                'cloudify.nodes.Root', 'cloudify.nodes.aws.iam.Role'
            ])
        current_ctx.set(_ctx)

        _target_ctx.instance.runtime_properties[
            'iam_role_id_key'] = 'role_field'
        instance_read_replica.prepare_assoc(
            ctx=_ctx,
            resource_config=None,
            iface=None,
            iam_role_type_key='iam_role_type_key',
            iam_role_id_key='iam_role_id_key')
        self.assertEqual(
            _source_ctx.instance.runtime_properties, {
                '_set_changed': True,
                'aws_resource_id': 'aws_resource_mock_id',
                'resource_config': {
                    'iam_role_type_key': 'role_field'
                },
                'resource_id': 'prepare_attach_source'
            })
Example #2
0
    def test_prepare_assoc_Role_NonRecoverableError(self):
        _source_ctx, _target_ctx, _ctx = self._create_common_relationships(
            'test_prepare_assoc',
            source_type_hierarchy=INSTANCE_READ_REPLICA_TH,
            target_type_hierarchy=[
                'cloudify.nodes.Root', 'cloudify.nodes.aws.iam.Role'
            ])
        current_ctx.set(_ctx)

        with self.assertRaises(NonRecoverableError) as error:
            instance_read_replica.prepare_assoc(ctx=_ctx,
                                                resource_config=None,
                                                iface=None)
        self.assertEqual(str(error.exception),
                         ('Missing required relationship inputs ' +
                          '"iam_role_type_key" and/or "iam_role_id_key".'))
Example #3
0
    def test_prepare_assoc_Instance(self):
        _source_ctx, _target_ctx, _ctx = self._create_common_relationships(
            'test_prepare_assoc',
            source_type_hierarchy=INSTANCE_READ_REPLICA_TH,
            target_type_hierarchy=[
                'cloudify.nodes.Root', 'cloudify.nodes.aws.rds.Instance'
            ])
        current_ctx.set(_ctx)

        instance_read_replica.prepare_assoc(ctx=_ctx,
                                            resource_config=None,
                                            iface=None)
        self.assertEqual(
            _source_ctx.instance.runtime_properties, {
                '_set_changed': True,
                'aws_resource_id': 'aws_resource_mock_id',
                'resource_config': {
                    'SourceDBInstanceIdentifier': 'aws_target_mock_id'
                },
                'resource_id': 'prepare_attach_source'
            })