コード例 #1
0
def test_repr_does_not_send_existence_required():
    """
    Ensure that `__repr__` method does not send `existance_required` signal

    Cachefile strategy may be configured to generate file on
    `existance_required`.
    To generate images, backend passes `ImageCacheFile` instance to worker.
    Both celery and RQ calls `__repr__` method for each argument to enque call.
    And if `__repr__` of object will send this signal, we will get endless
    recursion

    """
    with mock.patch('imagekit.cachefiles.existence_required') as signal:
        # import here to apply mock
        from imagekit.cachefiles import ImageCacheFile

        spec = TestSpec(source=get_unique_image_file())
        file = ImageCacheFile(spec,
                              cachefile_backend=DummyAsyncCacheFileBackend())
        file.__repr__()
        eq_(signal.send.called, False)
コード例 #2
0
def test_repr_does_not_send_existence_required():
    """
    Ensure that `__repr__` method does not send `existance_required` signal

    Cachefile strategy may be configured to generate file on
    `existance_required`.
    To generate images, backend passes `ImageCacheFile` instance to worker.
    Both celery and RQ calls `__repr__` method for each argument to enque call.
    And if `__repr__` of object will send this signal, we will get endless
    recursion

    """
    with mock.patch('imagekit.cachefiles.existence_required') as signal:
        # import here to apply mock
        from imagekit.cachefiles import ImageCacheFile

        spec = TestSpec(source=get_unique_image_file())
        file = ImageCacheFile(
            spec,
            cachefile_backend=DummyAsyncCacheFileBackend()
        )
        file.__repr__()
        eq_(signal.send.called, False)