Пример #1
0
    def test_basic(self):
        serviceArgument = ServiceArgument('foo.Bar')
        inspectedArgument = InspectedArgument('bar', DType('foo.Bar', 'Bar'))
        services2Classes = {'foo.Bar': DType('foo.Bar', 'Bar')}
        aliases2Services = {}

        serviceArgument.checkTypeMatchesDefinition(inspectedArgument,
                                                   services2Classes,
                                                   aliases2Services)
Пример #2
0
    def test_interface(self):
        serviceArgument = ServiceArgument('injecta.mocks.Bar')
        inspectedArgument = InspectedArgument(
            'bar', DType('injecta.mocks.BarInterface', 'BarInterface'))
        services2Classes = {
            'injecta.mocks.Bar': DType('injecta.mocks.Bar', 'Bar')
        }
        aliases2Services = {}

        serviceArgument.checkTypeMatchesDefinition(inspectedArgument,
                                                   services2Classes,
                                                   aliases2Services)
Пример #3
0
    def test_undefinedService(self):
        serviceArgument = ServiceArgument('foo.Bar')
        inspectedArgument = InspectedArgument('bar', DType('foo.Bar', 'Bar'))
        services2Classes = {}
        aliases2Services = {}

        with self.assertRaises(Exception) as error:
            serviceArgument.checkTypeMatchesDefinition(inspectedArgument,
                                                       services2Classes,
                                                       aliases2Services)

        self.assertEqual('Undefined service foo.Bar', str(error.exception))
Пример #4
0
    def test_unknownAliasedService(self):
        serviceArgument = ServiceArgument('foo.BarAlias')
        inspectedArgument = InspectedArgument('bar', DType('foo.Bar', 'Bar'))
        services2Classes = {}
        aliases2Services = {'foo.BarAlias': 'foo.Bar'}

        with self.assertRaises(Exception) as error:
            serviceArgument.checkTypeMatchesDefinition(inspectedArgument,
                                                       services2Classes,
                                                       aliases2Services)

        self.assertEqual('Aliased service "foo.Bar" does not exist',
                         str(error.exception))