Skip to content

Image scales cache does not work in tests #58

Open
@rafaelbco

Description

@rafaelbco

I recently updated from 2.0.9 to 3.0.11 in my buildout and noticed some test failures. I was able to identify the problem: when running tests, the image scales cache does not work.

The reason is in the following lines:

def modified(self):
"""Provide a callable to return the modification time of content
items, so stored image scales can be invalidated.
"""
context = aq_base(self.context)
date = DateTime(context._p_mtime)
return date.millis()

During tests, a content item may have the _p_mtime attribute set to None. So the code above is actually doing DateTime(None), which returns the current date/time. The result is every time a scale is requested it considers the cached value invalid, because the object is considered modified.

In the old version context.modified() was used instead of _p_mtime, and this method always returned a non-None value.

I wonder how to solve this problem. Maybe modified should return a default date in the past?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions