Exemplo n.º 1
0
    def test_execute_unsuccessful_purge(self):
        @pretend.call_recorder
        def find_service_factory(interface):
            raise ValueError

        config = pretend.stub(find_service_factory=find_service_factory)
        session = pretend.stub(info={
            "warehouse.legacy.api.xmlrpc.cache.purges":
            {"type_1", "type_2", "foobar"},
        }, )

        cache.execute_purge(config, session)

        assert find_service_factory.calls == [pretend.call(IXMLRPCCache)]
        assert "warehouse.legacy.api.xmlrpc.cache.purges" not in session.info
Exemplo n.º 2
0
    def test_execute_unsuccessful_purge(self):
        @pretend.call_recorder
        def find_service_factory(interface):
            raise ValueError

        config = pretend.stub(find_service_factory=find_service_factory)
        session = pretend.stub(
            info={
                "warehouse.legacy.api.xmlrpc.cache.purges": {
                    "type_1", "type_2", "foobar"
                },
            },
        )

        cache.execute_purge(config, session)

        assert find_service_factory.calls == [pretend.call(IXMLRPCCache)]
        assert "warehouse.legacy.api.xmlrpc.cache.purges" not in session.info
Exemplo n.º 3
0
    def test_execute_purge(self, app_config):
        service = pretend.stub(
            purge_tags=pretend.call_recorder(lambda purges: None))
        factory = pretend.call_recorder(lambda ctx, config: service)
        app_config.register_service_factory(factory, IXMLRPCCache)
        app_config.commit()
        session = pretend.stub(info={
            "warehouse.legacy.api.xmlrpc.cache.purges":
            {"type_1", "type_2", "foobar"},
        }, )

        cache.execute_purge(app_config, session)

        assert factory.calls == [pretend.call(None, app_config)]
        assert service.purge_tags.calls == [
            pretend.call({"type_1", "type_2", "foobar"})
        ]
        assert "warehouse.legacy.api.xmlrpc.cache.purges" not in session.info
Exemplo n.º 4
0
    def test_execute_purge(self, app_config):
        service = pretend.stub(purge_tags=pretend.call_recorder(lambda purges: None))
        factory = pretend.call_recorder(lambda ctx, config: service)
        app_config.register_service_factory(factory, IXMLRPCCache)
        app_config.commit()
        session = pretend.stub(
            info={
                "warehouse.legacy.api.xmlrpc.cache.purges": {
                    "type_1",
                    "type_2",
                    "foobar",
                }
            }
        )

        cache.execute_purge(app_config, session)

        assert factory.calls == [pretend.call(None, app_config)]
        assert service.purge_tags.calls == [
            pretend.call({"type_1", "type_2", "foobar"})
        ]
        assert "warehouse.legacy.api.xmlrpc.cache.purges" not in session.info