Ejemplo n.º 1
0
    def test_multiple_cleanups_for_same_url(self, transport):
        callbacks = ClenaupCallbacks()

        client = Client(transport)
        client.add_cleanup('/foo', callbacks.cleanup1)
        client.add_cleanup('/foo', callbacks.cleanup2)

        client.cleanup()

        assert sorted(callbacks.calls) == sorted(['cleanup1', 'cleanup2'])
Ejemplo n.º 2
0
    def test_removal_of_multiple_cleanups_for_same_url(self, transport):
        callbacks = ClenaupCallbacks()

        client = Client(transport)
        client.add_cleanup('/foo', callbacks.cleanup1)
        client.add_cleanup('/foo', callbacks.cleanup2)
        client.remove_cleanup('/foo')

        client.cleanup()

        assert callbacks.calls == []
Ejemplo n.º 3
0
    def test_removing_cleanup_callback(self, transport):
        class Callbacks:
            def __init__(self):
                self.calls = []

            def cleanup1(self):
                self.calls.append('cleanup1')

            def cleanup2(self):
                self.calls.append('cleanup2')

        callbacks = Callbacks()

        client = Client(transport)
        client.add_cleanup('/foo', callbacks.cleanup1)
        client.add_cleanup('/bar', callbacks.cleanup2)
        client.remove_cleanup('/foo')

        client.cleanup()

        assert sorted(callbacks.calls) == sorted(['cleanup2'])
Ejemplo n.º 4
0
    def test_cleanup_executes_all_registered_cleanup_callbacks(
            self, transport):
        class Callbacks:
            def __init__(self):
                self.calls = []

            def cleanup1(self):
                self.calls.append('cleanup1')

            def cleanup2(self):
                self.calls.append('cleanup2')

        callbacks = Callbacks()

        client = Client(transport)
        client.add_cleanup('/foo', callbacks.cleanup1)
        client.add_cleanup('/bar', callbacks.cleanup2)

        client.cleanup()

        assert sorted(callbacks.calls) == sorted(['cleanup1', 'cleanup2'])