Esempio n. 1
0
def test_get_index_entry_queryset():
    now = timezone.now()

    pinned_post1 = PostFactory(
        status=Post.STATUS_CHOICES.published,
        pinned=True,
        show_on_index=True,
        pub_date=now,
    )
    pinned_post2 = PostFactory(
        status=Post.STATUS_CHOICES.published,
        pinned=True,
        show_on_index=True,
        pub_date=now - timedelta(days=1),
    )
    material = MaterialFactory(status=Material.STATUS.published,
                               show_on_index=True,
                               pub_date=now)
    post = PostFactory(
        status=Post.STATUS_CHOICES.published,
        pinned=False,
        show_on_index=True,
        pub_date=now - timedelta(days=1),
    )

    expected = [pinned_post1.id, pinned_post2.id, material.id, post.id]
    assert [entry.id for entry in get_index_entry_queryset()] == expected
 def get_queryset(self):
     return get_index_entry_queryset()