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