Beispiel #1
0
    def test_pipeline_contextmanager_disabled(self, stats_client_cls,
                                              stats_config):
        stats_config['enabled'] = False
        lc = LazyClient(**stats_config)

        with lc.pipeline() as pipe:
            pipe.incr('foo')
            pipe.send()

        assert isinstance(pipe, Mock)
        assert lc.client.pipeline.mock_calls == []
Beispiel #2
0
    def test_pipeline_contextmanager_enabled(self, stats_client_cls,
                                             stats_config):
        lc = LazyClient(**stats_config)

        with lc.pipeline() as pipe:
            pipe.incr('foo')
            pipe.send()

        assert pipe is lc.client.pipeline.return_value.__enter__.return_value
        assert lc.client.pipeline.mock_calls == [
            call(),
            call().__enter__(),
            call().__enter__().incr('foo'),
            call().__enter__().send(),
            call().__exit__(None, None, None)
        ]