+ def assert_publishable(self):
+ assert self.chunk_set.exists(), _('No chunks in the book.')
+ try:
+ changes = self.get_current_changes()
+ except self.NoTextError:
+ raise AssertionError(_('Not all chunks have publishable revisions.'))
+
+ from librarian import NoDublinCore, ParseError, ValidationError
+
+ try:
+ bi = self.wldocument(changes=changes, strict=True).book_info
+ if not bi.audience:
+ raise ValidationError('No audience specified')
+ if not bi.type:
+ raise ValidationError('No type specified')
+ except ParseError, e:
+ raise AssertionError(_('Invalid XML') + ': ' + unicode(e))
+ except NoDublinCore:
+ raise AssertionError(_('No Dublin Core found.'))
+ except ValidationError, e:
+ raise AssertionError(_('Invalid Dublin Core') + ': ' + unicode(e))
+
+ valid_about = self.correct_about()
+ assert bi.about == valid_about, _("rdf:about is not") + " " + valid_about
+
+ def publishable_error(self):
+ try:
+ return self.assert_publishable()
+ except AssertionError, e:
+ return e