def test_authorships_should_clear_authors_when_empty(self):
     from zope.lifecycleevent import ObjectModifiedEvent, Attributes
     from zeit.cms.content.interfaces import ICommonMetadata
     from zeit.content.author.author import update_author_freetext
     content = mock.Mock()
     content.authors = mock.sentinel.unchanged
     content.authorships = ()
     event = ObjectModifiedEvent(content,
                                 Attributes(ICommonMetadata, 'authorships'))
     update_author_freetext(content, event)
     self.assertEqual([], content.authors)
 def test_authorships_should_clear_authors_when_empty(self):
     from zope.lifecycleevent import ObjectModifiedEvent, Attributes
     from zeit.cms.content.interfaces import ICommonMetadata
     from zeit.content.author.author import update_author_freetext
     content = mock.Mock()
     content.authors = mock.sentinel.unchanged
     content.authorships = ()
     event = ObjectModifiedEvent(
         content, Attributes(ICommonMetadata, 'authorships'))
     update_author_freetext(content, event)
     self.assertEqual([], content.authors)
 def test_authorships_should_not_be_copied_for_other_field_change(self):
     from zope.lifecycleevent import ObjectModifiedEvent, Attributes
     from zeit.cms.content.interfaces import ICommonMetadata
     from zeit.content.author.author import update_author_freetext
     content = mock.Mock()
     content.authors = mock.sentinel.unchanged
     author1, author2 = mock.Mock(), mock.Mock()
     content.authorships = (author1, author2)
     event = ObjectModifiedEvent(content,
                                 Attributes(ICommonMetadata, 'some-field'))
     update_author_freetext(content, event)
     self.assertEqual(mock.sentinel.unchanged, content.authors)
 def test_authorships_should_not_be_copied_for_other_field_change(
         self):
     from zope.lifecycleevent import ObjectModifiedEvent, Attributes
     from zeit.cms.content.interfaces import ICommonMetadata
     from zeit.content.author.author import update_author_freetext
     content = mock.Mock()
     content.authors = mock.sentinel.unchanged
     author1, author2 = mock.Mock(), mock.Mock()
     content.authorships = (author1, author2)
     event = ObjectModifiedEvent(
         content, Attributes(ICommonMetadata, 'some-field'))
     update_author_freetext(content, event)
     self.assertEqual(mock.sentinel.unchanged, content.authors)
 def test_authorships_should_be_copied_to_freetext(self):
     from zope.lifecycleevent import ObjectModifiedEvent, Attributes
     from zeit.cms.content.interfaces import ICommonMetadata
     from zeit.content.author.author import update_author_freetext
     content = mock.Mock()
     author1, author2 = mock.Mock(), mock.Mock()
     author1.target.display_name = mock.sentinel.author1
     author2.target.display_name = mock.sentinel.author2
     content.authorships = (author1, author2)
     event = ObjectModifiedEvent(content,
                                 Attributes(ICommonMetadata, 'authorships'))
     update_author_freetext(content, event)
     self.assertEqual([mock.sentinel.author1, mock.sentinel.author2],
                      content.authors)
 def test_authorships_should_be_copied_to_freetext(self):
     from zope.lifecycleevent import ObjectModifiedEvent, Attributes
     from zeit.cms.content.interfaces import ICommonMetadata
     from zeit.content.author.author import update_author_freetext
     content = mock.Mock()
     author1, author2 = mock.Mock(), mock.Mock()
     author1.target.display_name = mock.sentinel.author1
     author2.target.display_name = mock.sentinel.author2
     content.authorships = (author1, author2)
     event = ObjectModifiedEvent(
         content, Attributes(ICommonMetadata, 'authorships'))
     update_author_freetext(content, event)
     self.assertEqual([mock.sentinel.author1, mock.sentinel.author2],
                      content.authors)