Example #1
0
    def test_prioritized_ignores_missing_plugin(self):
        fake_plugin = stub(name='foo', priority=50)
        registry.plugins = {'foo': fake_plugin}
        registry.enabled_plugins['#bots'] = set(['foo', 'bar'])

        items = registry.prioritized('#bots')

        assert len(items) == 1
        assert items[0].name == 'foo'
Example #2
0
    def test_prioritized_ignores_missing_plugin(self):
        fake_plugin = stub(name='foo', priority=50)
        registry.plugins = {'foo': fake_plugin}
        registry.enabled_plugins['#bots'] = set(['foo', 'bar'])

        items = registry.prioritized('#bots')

        assert len(items) == 1
        assert items[0].name == 'foo'
Example #3
0
    def test_prioritized_reversed(self):
        fake_plugin = stub(name='foo', priority=50)
        fake_decorated = stub(_plugins=[
            stub(name='bar', priority=10),
            stub(name='baz', priority=0),
            stub(name=self.snowman, priority=99),
        ])
        registry.plugins = {'foo': fake_plugin, 'bar': fake_decorated}
        registry.enabled_plugins['#bots'] = set(['foo', 'bar'])

        items = registry.prioritized('#bots', high_to_low=False)

        assert items[3].name == self.snowman
        assert items[2].name == 'foo'
        assert items[1].name == 'bar'
        assert items[0].name == 'baz'
Example #4
0
    def test_prioritized_reversed(self):
        fake_plugin = stub(name='foo', priority=50)
        fake_decorated = stub(_plugins=[
            stub(name='bar', priority=10),
            stub(name='baz', priority=0),
            stub(name=self.snowman, priority=99),
        ])
        registry.plugins = {'foo': fake_plugin, 'bar': fake_decorated}
        registry.enabled_plugins['#bots'] = set(['foo', 'bar'])

        items = registry.prioritized('#bots', high_to_low=False)

        assert items[3].name == self.snowman
        assert items[2].name == 'foo'
        assert items[1].name == 'bar'
        assert items[0].name == 'baz'