示例#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)
示例#2
0
文件: tests.py 项目: kapito/wagtail
    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)
示例#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)
示例#4
0
文件: tests.py 项目: kapito/wagtail
 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)