Improve tests

This commit is contained in:
Iacopo Spalletti 2016-03-26 11:55:20 +01:00
parent 6c7e1b72f8
commit 5868a9face
1 changed files with 42 additions and 0 deletions

View File

@ -3,6 +3,7 @@ from __future__ import absolute_import, print_function, unicode_literals
import re
from copy import deepcopy
from datetime import timedelta
import parler
from cms.api import add_plugin
@ -335,6 +336,47 @@ class ModelsTest(BaseTest):
post.meta_title = 'meta title'
self.assertEqual(post.get_title(), 'meta title')
# Assess is_published property
post.publish = False
post.save()
self.assertFalse(post.is_published)
post.publish = True
post.date_published = now() + timedelta(days=1)
post.date_published_end = None
post.save()
self.assertFalse(post.is_published)
post.publish = True
post.date_published = now() - timedelta(days=1)
post.date_published_end = now() - timedelta(minutes=1)
post.save()
self.assertFalse(post.is_published)
post.publish = True
post.date_published = now() - timedelta(days=1)
post.date_published_end = None
post.save()
self.assertTrue(post.is_published)
post.publish = True
post.date_published = now() - timedelta(days=1)
post.date_published_end = now() + timedelta(minutes=1)
post.save()
self.assertTrue(post.is_published)
post.publish = False
post.date_published = now() - timedelta(days=1)
post.date_published_end = None
post.save()
self.assertFalse(post.is_published)
post.publish = False
post.date_published = now() - timedelta(days=1)
post.date_published_end = now() + timedelta(minutes=1)
post.save()
self.assertFalse(post.is_published)
def test_urls(self):
self.get_pages()
post = self._get_post(self._post_data[0]['en'])