Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)