Révision 2a14e3e1
Ajouté par Serghei Mihai il y a plus de 7 ans
tests/test_announces.py | ||
---|---|---|
4 | 4 |
import feedparser |
5 | 5 |
|
6 | 6 |
from django.core.files.storage import DefaultStorage |
7 |
from django.utils import timezone |
|
8 |
from django.core.urlresolvers import reverse |
|
7 | 9 |
|
8 |
from corbo.models import Category |
|
10 |
from corbo.models import Category, Announce
|
|
9 | 11 |
|
10 | 12 |
pytestmark = pytest.mark.django_db |
11 | 13 |
|
... | ... | |
62 | 64 |
assert storage.url('logo.png') in announce.text |
63 | 65 |
# cleanup uploaded images |
64 | 66 |
os.unlink(storage.path('logo.png')) |
67 |
|
|
68 |
|
|
69 |
def test_announces_publishing(app): |
|
70 |
c = Category.objects.create(name='Test announces') |
|
71 |
a = Announce.objects.create(category=c, title='Test 1', |
|
72 |
text='text') |
|
73 |
feed_content = feedparser.parse(app.get(reverse('atom')).text) |
|
74 |
assert len(feed_content['entries']) == 0 |
|
75 |
a.publication_time = timezone.now() |
|
76 |
a.save() |
|
77 |
feed_content = feedparser.parse(app.get(reverse('atom')).text) |
|
78 |
assert len(feed_content['entries']) == 1 |
|
79 |
a.publication_time = timezone.now() + timezone.timedelta(days=1) |
|
80 |
a.save() |
|
81 |
feed_content = feedparser.parse(app.get(reverse('atom')).text) |
|
82 |
assert len(feed_content['entries']) == 0 |
|
83 |
a.publication_time = timezone.now() |
|
84 |
a.expiration_time = timezone.now() |
|
85 |
a.save() |
|
86 |
feed_content = feedparser.parse(app.get(reverse('atom')).text) |
|
87 |
assert len(feed_content['entries']) == 0 |
Formats disponibles : Unified diff
rss: expose published announces only (#14731)