Ejemplo n.º 1
0
    def test_multiple(self):
        # This tests a bunch of different renames working together
        model = ResourceModel(
            'test', {
                'identifiers': [{
                    'name': 'Foo'
                }],
                'actions': {
                    'Foo': {}
                },
                'has': {
                    'Foo': {
                        'resource': {
                            'type':
                            'Frob',
                            'identifiers': [{
                                'target': 'Id',
                                'source': 'data',
                                'path': 'FrobId'
                            }]
                        }
                    }
                },
                'hasMany': {
                    'Foo': {}
                },
                'waiters': {
                    'Foo': {}
                }
            }, {'Frob': {}})

        shape = DenormalizedStructureBuilder().with_members({
            'Foo': {
                'type': 'string',
            },
            'Bar': {
                'type': 'string'
            }
        }).build_model()

        model.load_rename_map(shape)

        assert model.identifiers[0].name == 'foo'
        assert model.actions[0].name == 'foo_action'
        assert model.references[0].name == 'foo_reference'
        assert model.collections[0].name == 'foo_collection'
        assert model.waiters[0].name == 'wait_until_foo'

        # If an identifier and an attribute share the same name, then
        # the attribute is essentially hidden.
        assert 'foo_attribute' not in model.get_attributes(shape)

        # Other attributes need to be there, though
        assert 'bar' in model.get_attributes(shape)
Ejemplo n.º 2
0
    def test_multiple(self):
        # This tests a bunch of different renames working together
        model = ResourceModel('test', {
            'identifiers': [{'name': 'Foo'}],
            'actions': {
                'Foo': {}
            },
            'has': {
                'Foo': {
                    'resource': {
                        'type': 'Frob',
                        'identifiers': [
                            {'target':'Id', 'source':'data',
                             'path': 'FrobId'}
                        ]
                    }
                }
            },
            'hasMany': {
                'Foo': {}
            },
            'waiters': {
                'Foo': {}
            }
        }, {
            'Frob': {}
        })

        shape = DenormalizedStructureBuilder().with_members({
            'Foo': {
                'type': 'string',
            },
            'Bar': {
                'type': 'string'
            }
        }).build_model()

        model.load_rename_map(shape)

        self.assertEqual(model.identifiers[0].name, 'foo')
        self.assertEqual(model.actions[0].name, 'foo_action')
        self.assertEqual(model.references[0].name, 'foo_reference')
        self.assertEqual(model.collections[0].name, 'foo_collection')
        self.assertEqual(model.waiters[0].name, 'wait_until_foo')

        # If an identifier and an attribute share the same name, then
        # the attribute is essentially hidden.
        self.assertNotIn('foo_attribute', model.get_attributes(shape))

        # Other attributes need to be there, though
        self.assertIn('bar', model.get_attributes(shape))
Ejemplo n.º 3
0
    def test_waiter_beats_attribute(self):
        model = ResourceModel('test', {'waiters': {'Foo': {}}}, {'Frob': {}})

        shape = DenormalizedStructureBuilder().with_members({
            'WaitUntilFoo': {
                'type': 'string',
            }
        }).build_model()

        model.load_rename_map(shape)

        assert model.waiters[0].name == 'wait_until_foo'
        assert 'wait_until_foo_attribute' in model.get_attributes(shape)
Ejemplo n.º 4
0
    def test_waiter_beats_attribute(self):
        model = ResourceModel('test', {
            'waiters': {
                'Foo': {}
            }
        }, {'Frob': {}})

        shape = DenormalizedStructureBuilder().with_members({
            'WaitUntilFoo': {
                'type': 'string',
            }
        }).build_model()

        model.load_rename_map(shape)

        self.assertEqual(model.waiters[0].name, 'wait_until_foo')
        self.assertIn('wait_until_foo_attribute', model.get_attributes(shape))