def _check_pre_publish(self, queryset): pre_published = [] def pre_publish_handler(sender, instance, **kw): pre_published.append(instance) pre_publish.connect(pre_publish_handler, sender=Page) queryset.draft().publish() self.failUnlessEqual(queryset.draft().count(), len(pre_published)) self.failUnlessEqual(set(queryset.draft()), set(pre_published))
def test_deleted_flag_false_when_publishing_change(self): def pre_publish_handler(sender, instance, deleted, **kw): self.failIf(deleted) pre_publish.connect(pre_publish_handler, sender=Page) def post_publish_handler(sender, instance, deleted, **kw): self.failIf(deleted) post_publish.connect(post_publish_handler, sender=Page) self.page1.publish()
def test_deleted_flag_true_when_publishing_deletion(self): self.child1.publish() self.child1.public self.child1.delete() self.failUnlessEqual(Publishable.PUBLISH_DELETE, self.child1.publish_state) def pre_publish_handler(sender, instance, deleted, **kw): self.failUnless(deleted) pre_publish.connect(pre_publish_handler, sender=Page) def post_publish_handler(sender, instance, deleted, **kw): self.failUnless(deleted) post_publish.connect(post_publish_handler, sender=Page) self.child1.publish()
def test_signals_sent_for_followed(self): pre_published = [] def pre_publish_handler(sender, instance, **kw): pre_published.append(instance) pre_publish.connect(pre_publish_handler, sender=Page) published = [] def post_publish_handler(sender, instance, **kw): published.append(instance) post_publish.connect(post_publish_handler, sender=Page) # publishing just children will also publish it's parent (if needed) # which should also fire signals self.child1.publish() self.failUnlessEqual(set([self.page1, self.child1]), set(pre_published)) self.failUnlessEqual(set([self.page1, self.child1]), set(published))