def test_applies_values_to_cms_object(self): from zeit.content.author.author import Author self.repository['a1'] = Author() cms = CMSVideo() bc = BCVideo() bc.data = { 'id': 'myvid', 'name': 'title', 'created_at': '2017-05-15T08:24:55.916Z', 'schedule': { 'ends_at': '2018-03-13T23:00:00.000Z', 'starts_at': None }, 'state': 'ACTIVE', 'economics': 'AD_SUPPORTED', 'custom_fields': { 'allow_comments': '1', 'authors': 'http://xml.zeit.de/a1', 'channels': 'Deutschland Meinung;International', 'cmskeywords': 'testtag;testtag2', 'produkt-id': 'TEST', 'ref_link1': 'http://xml.zeit.de/online/2007/01/eta-zapatero', 'serie': 'Chefsache', }, 'images': { 'thumbnail': { 'src': 'http://example.com/thumbnail' }, 'poster': { 'src': 'http://example.com/still' }, }, 'sources': [{ 'src': 'http://example.com/rendition', }], } bc.apply_to_cms(cms) self.assertEqual('myvid', cms.external_id) self.assertEqual('title', cms.title) self.assertEqual(True, cms.commentsAllowed) self.assertEqual(['http://xml.zeit.de/a1'], [x.target.uniqueId for x in cms.authorships]) self.assertEqual(['testtag', 'testtag2'], [x.code for x in cms.keywords]) self.assertEqual((('Deutschland', 'Meinung'), ('International', None)), cms.channels) self.assertEqual('TEST', cms.product.id) self.assertEqual(True, cms.has_advertisement) self.assertEqual( (zeit.cms.interfaces.ICMSContent( 'http://xml.zeit.de/online/2007/01/eta-zapatero'), ), zeit.cms.related.interfaces.IRelatedContent(cms).related) self.assertEqual('Chefsache', cms.serie.serienname) self.assertEqual(datetime(2018, 3, 13, 23, 0, tzinfo=pytz.UTC), cms.expires)
def test_product_defaults_to_reuters(self): bc = BCVideo() bc.data['reference_id'] = '1234' cms = CMSVideo() bc.apply_to_cms(cms) self.assertEqual('Reuters', cms.product.id)
def test_non_brightcove_fields_use_default(self): bc = BCVideo() cms = CMSVideo() bc.apply_to_cms(cms) self.assertTrue(cms.lead_candidate)
def test_missing_values_use_field_default(self): bc = BCVideo() cms = CMSVideo() bc.apply_to_cms(cms) self.assertTrue(cms.commentsAllowed)