fix outdated content_object_init refs

* remove content_object_init section from docs
* improve content_object_init test

The content_object_init signal used to set its class as sender and pass
the instance as additional arg in 6100773. Commit ed907b4 removed this
behaviour to bring it inline with other signals, on the basis that
you can test for the class of the object anyway.
We also had a test in place, checking this behaviour, but it was poorly
implemented, not actually checking if the function ever got called.

closes #1711
This commit is contained in:
derwinlu 2015-06-11 19:40:34 +02:00
commit e3f5e39e17
2 changed files with 20 additions and 33 deletions

View file

@ -1,18 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import
import six
from sys import platform
import locale
import os.path
import six
from pelican.tests.support import unittest, get_settings
from pelican.contents import Page, Article, Static, URLWrapper, Author, Category
from pelican.settings import DEFAULT_CONFIG
from pelican.utils import path_to_url, truncate_html_words, SafeDatetime, posix_join
from pelican.signals import content_object_init
from jinja2.utils import generate_lorem_ipsum
from sys import platform
from pelican.contents import (Page, Article, Static, URLWrapper,
Author, Category)
from pelican.settings import DEFAULT_CONFIG
from pelican.signals import content_object_init
from pelican.tests.support import unittest, get_settings
from pelican.utils import (path_to_url, truncate_html_words, SafeDatetime,
posix_join)
# generate one paragraph, enclosed with <p>
TEST_CONTENT = str(generate_lorem_ipsum(n=1))
@ -191,14 +193,19 @@ class TestPage(unittest.TestCase):
return page_kwargs
def test_signal(self):
# If a title is given, it should be used to generate the slug.
def receiver_test_function(sender, instance):
def receiver_test_function(sender):
receiver_test_function.has_been_called = True
pass
receiver_test_function.has_been_called = False
content_object_init.connect(receiver_test_function, sender=Page)
content_object_init.connect(receiver_test_function)
self.assertIn(
receiver_test_function,
content_object_init.receivers_for(Page))
self.assertFalse(receiver_test_function.has_been_called)
Page(**self.page_kwargs)
self.assertTrue(content_object_init.has_receivers_for(Page))
self.assertTrue(receiver_test_function.has_been_called)
def test_get_content(self):
# Test that the content is updated with the relative links to