0002-cells-a-cell-is-not-visible-after-2-days-of-invalidi.patch
combo/data/models.py | ||
---|---|---|
725 | 725 |
return {} |
726 | 726 | |
727 | 727 |
def is_visible(self, user=None): |
728 |
if self.invalid_since and self.invalid_since < now() - datetime.timedelta(days=2): |
|
729 |
return False |
|
728 | 730 |
return element_is_visible(self, user=user) |
729 | 731 | |
730 | 732 |
def is_relevant(self, context): |
tests/test_cells.py | ||
---|---|---|
1 |
import datetime |
|
1 | 2 |
import json |
2 | 3 |
import mock |
3 | 4 |
import os |
... | ... | |
18 | 19 |
from django.contrib.auth.models import User |
19 | 20 |
from django.core.urlresolvers import reverse |
20 | 21 |
from django.utils.encoding import force_text, force_bytes |
22 |
from django.utils.timezone import now |
|
21 | 23 | |
22 | 24 |
from combo.data.library import get_cell_classes |
23 | 25 |
from combo.utils import NothingInCacheException |
... | ... | |
787 | 789 |
assert new_item.title == item.title |
788 | 790 |
assert new_item.url == item.url |
789 | 791 |
assert new_item.link_page == item.link_page |
792 | ||
793 | ||
794 |
def test_cell_is_visible(): |
|
795 |
cell = CellBase() |
|
796 |
assert cell.is_visible() is True |
|
797 | ||
798 |
# invalid cell since just now |
|
799 |
cell.invalid_reason_code = 'FOO' |
|
800 |
cell.invalid_since = now() |
|
801 |
assert cell.is_visible() is True |
|
802 | ||
803 |
# invalid cell since two days |
|
804 |
cell.invalid_since = now() - datetime.timedelta(days=2) |
|
805 |
assert cell.is_visible() is False |
|
790 |
- |