def test_ping_directories_handler(self): # Set up a stub around DirectoryPinger self.top = 0 def fake_pinger(*ka, **kw): self.top += 1 import zinnia.ping from zinnia import settings self.original_pinger = zinnia.ping.DirectoryPinger zinnia.ping.DirectoryPinger = fake_pinger params = { 'title': 'My entry', 'content': 'My content', 'status': PUBLISHED, 'slug': 'my-entry' } entry = Entry.objects.create(**params) self.assertEquals(entry.is_visible, True) settings.SAVE_PING_DIRECTORIES = () ping_directories_handler('sender', **{'instance': entry}) self.assertEquals(self.top, 0) settings.SAVE_PING_DIRECTORIES = ('toto', ) ping_directories_handler('sender', **{'instance': entry}) self.assertEquals(self.top, 1) entry.status = 0 ping_directories_handler('sender', **{'instance': entry}) self.assertEquals(self.top, 1) # Remove stub zinnia.ping.DirectoryPinger = self.original_pinger
def test_ping_directories_handler(self): # Set up a stub around DirectoryPinger self.top = 0 def fake_pinger(*ka, **kw): self.top += 1 import zinnia.ping from zinnia import settings self.original_pinger = zinnia.ping.DirectoryPinger zinnia.ping.DirectoryPinger = fake_pinger params = {'title': 'My entry', 'content': 'My content', 'status': PUBLISHED, 'slug': 'my-entry'} entry = Entry.objects.create(**params) self.assertEquals(entry.is_visible, True) settings.PING_DIRECTORIES = () ping_directories_handler('sender', **{'instance': entry}) self.assertEquals(self.top, 0) settings.PING_DIRECTORIES = ('toto',) settings.SAVE_PING_DIRECTORIES = True ping_directories_handler('sender', **{'instance': entry}) self.assertEquals(self.top, 1) entry.status = DRAFT ping_directories_handler('sender', **{'instance': entry}) self.assertEquals(self.top, 1) # Remove stub zinnia.ping.DirectoryPinger = self.original_pinger