Exemple #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)
Exemple #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}
Exemple #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}
Exemple #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)
Exemple #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)
    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)
Exemple #7
0
    def test_get_backends_with_zero_backends_should_return_empty_list(self):
        configure(pools={BackendPool.backend_type: {}})

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

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

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

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

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

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