

def test_dangling_resource_loads_data(self):
    self.defs = {
        'Instance': {
            'identifiers': [{
                'name': 'Id',
            }],
            'has': {
                'NetworkInterface': {
                    'resource': {
                        'type': 'NetworkInterface',
                        'identifiers': [{
                            'target': 'Id',
                            'source': 'data',
                            'path': 'NetworkInterface.Id',
                        }],
                        'path': 'NetworkInterface',
                    },
                },
            },
        },
        'NetworkInterface': {
            'identifiers': [{
                'name': 'Id',
            }],
            'shape': 'NetworkInterfaceShape',
        },
    }
    self.model = self.defs['Instance']
    shape = DenormalizedStructureBuilder().with_members({
        'Id': {
            'type': 'string',
        },
        'PublicIp': {
            'type': 'string',
        },
    }).build_model()
    service_model = mock.Mock()
    service_model.shape_for.return_value = shape
    cls = self.load('Instance', self.model, self.defs, service_model)
    instance = cls('instance-id')

    def set_meta_data():
        instance.meta.data = {
            'NetworkInterface': {
                'Id': 'network-interface-id',
                'PublicIp': '127.0.0.1',
            },
        }
    instance.load = mock.Mock(side_effect=set_meta_data)
    interface = instance.network_interface
    self.assertIsNotNone(interface.meta.data)
    self.assertEqual(interface.public_ip, '127.0.0.1')

dataset/ETHPy150Open boto/boto3/tests/unit/resources/test_factory.py TestResourceFactoryDanglingResource.test_dangling_resource_loads_data/original