Esempio n. 1
0
    def test_get_backends_should_return_all_backends_instances(
        self, configured_pools
    ):
        backends = BackendPool.all()

        assert isinstance(backends[0], FakeXYZBackend)
        assert isinstance(backends[1], FakeABCBackend)
Esempio n. 2
0
    def test_all_should_pass_args_to_the_backend_constructor(
        self, configured_pool_with_fake_backend_with_constructor
    ):
        backends = BackendPool.all('arg1', 'arg2', arg3=3, arg4=4)
        backend = backends[0]

        assert backend.args == ('arg1', 'arg2')
        assert backend.kwargs == {'arg3': 3, 'arg4': 4}
Esempio n. 3
0
    def test_all_should_pass_args_to_the_backend_constructor(self):
        configure(
            pools={
                BackendPool.backend_type: (u'{module}.{cls}'.format(
                    module=__name__, cls=FakeBackendWithConstructor.__name__),
                                           )
            })

        backends = BackendPool.all('arg1', 'arg2', arg3=3, arg4=4)
        backend = backends[0]

        assert backend.args == ('arg1', 'arg2')
        assert backend.kwargs == {'arg3': 3, 'arg4': 4}
Esempio n. 4
0
    def test_get_backends_should_return_all_backends_instances(self):
        configure(
            pools={
                BackendPool.backend_type: (
                    u'{module}.{cls}'.format(module=__name__,
                                             cls=FakeXYZBackend.__name__),
                    u'{module}.{cls}'.format(module=__name__,
                                             cls=FakeABCBackend.__name__),
                )
            })

        backends = BackendPool.all()

        assert isinstance(backends[0], FakeXYZBackend)
        assert isinstance(backends[1], FakeABCBackend)
Esempio n. 5
0
    def test_get_backends_should_return_all_backends_instances(self):
        configure(pools={
            BackendPool.backend_type: (
                u'{module}.{cls}'.format(
                    module=__name__,
                    cls=FakeXYZBackend.__name__
                ),
                u'{module}.{cls}'.format(
                    module=__name__,
                    cls=FakeABCBackend.__name__
                ),
            )
        })

        backends = BackendPool.all()

        assert isinstance(backends[0], FakeXYZBackend)
        assert isinstance(backends[1], FakeABCBackend)
Esempio n. 6
0
    def test_get_backends_should_return_all_backends_instances(self):
        settings.POOL_OF_RAMOS = {
            BackendPool.backend_type: (
                u'{module}.{cls}'.format(
                    module=__name__,
                    cls=FakeXYZBackend.__name__
                ),
                u'{module}.{cls}'.format(
                    module=__name__,
                    cls=FakeABCBackend.__name__
                ),
            )
        }

        backends = BackendPool.all()

        assert isinstance(backends[0], FakeXYZBackend)
        assert isinstance(backends[1], FakeABCBackend)
Esempio n. 7
0
    def test_get_backends_with_zero_backends_should_return_empty_list(self):
        configure(pools={BackendPool.backend_type: {}})

        assert BackendPool.all() == []
Esempio n. 8
0
    def test_get_backends_without_config_should_raise(self):
        configure(pools={})

        with pytest.raises(ImproperlyConfigured):
            BackendPool.all()
Esempio n. 9
0
    def test_get_backends_with_zero_backends_should_return_empty_list(self):
        configure(pools={
            BackendPool.backend_type: {}
        })

        assert BackendPool.all() == []
Esempio n. 10
0
    def test_get_backends_without_config_should_raise(self):
        configure(pools={})

        with pytest.raises(ImproperlyConfigured):
            BackendPool.all()
Esempio n. 11
0
    def test_get_backends_with_zero_backends_should_return_empty_list(self):
        settings.POOL_OF_RAMOS = {
            BackendPool.backend_type: {}
        }

        assert BackendPool.all() == []
Esempio n. 12
0
    def test_get_backends_without_config_should_raise(self):
        settings.POOL_OF_RAMOS = {}

        with pytest.raises(ImproperlyConfigured):
            BackendPool.all()