Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 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)