Example #1
0
 def test_create_reference_raises_given_a_reference(self):
     content = self.repository['content']
     with self.assertRaises(TypeError) as e:
         ReferenceProperty.create_reference(
             source=content, attribute='references',
             target=content.references.create(self.repository['target']),
             xml_reference_name='test')
     self.assertIn('data loss', str(e.exception))
Example #2
0
 def test_create_reference_raises_given_a_reference_even_if_suppress_error(
         self):
     # Suppressing errors is only forwarded to the XMLReferenceUpdater.
     # It does not mean that the method itself does not raise errors.
     content = self.repository['content']
     with self.assertRaises(TypeError) as e:
         ReferenceProperty.create_reference(
             source=content, attribute='references',
             target=content.references.create(self.repository['target']),
             xml_reference_name='test', suppress_errors=True)
     self.assertIn('data loss', str(e.exception))
Example #3
0
 def test_create_reference_accepts_ICMSContent(self):
     from zeit.cms.content.interfaces import IReference
     content = self.repository['content']
     target = self.repository['target']
     result = ReferenceProperty.create_reference(
         source=content, attribute='references', target=target,
         xml_reference_name='test')
     self.assertTrue(IReference.providedBy(result))
     self.assertEqual(target.uniqueId, result.target.uniqueId)