def test_serialize(self): """The value of a SnippetChooserBlock (a snippet instance) should serialize to an ID""" block = SnippetChooserBlock(AdvertWithCustomPrimaryKey) test_advert = AdvertWithCustomPrimaryKey.objects.get(pk='advert/01') self.assertEqual(block.get_prep_value(test_advert), test_advert.pk) # None should serialize to None self.assertEqual(block.get_prep_value(None), None)
def test_serialize(self): """The value of a SnippetChooserBlock (a snippet instance) should serialize to an ID""" block = SnippetChooserBlock(Advert) test_advert = Advert.objects.get(text='test_advert') self.assertEqual(block.get_prep_value(test_advert), test_advert.id) # None should serialize to None self.assertEqual(block.get_prep_value(None), None)