def test_get_mapping(self):
        field = FileField()

        expected_type = 'string' if ES_MAJOR_VERSION == 2 else 'text'

        self.assertEqual({
            'type': expected_type,
        }, field.to_dict())
Exemplo n.º 2
0
    def test_get_value_from_instance(self):
        field = FileField(attr='file')

        instance = NonCallableMock(file=NonCallableMock(spec=FieldFile,
                                                        url='myfile.pdf'), )
        self.assertEqual(field.get_value_from_instance(instance), 'myfile.pdf')

        field = FileField(attr='related.attr1')
        instance = NonCallableMock(attr1="foo",
                                   related=NonCallableMock(attr1="bar"))
        self.assertEqual(field.get_value_from_instance(instance), 'bar')
 def test_get_mapping(self):
     field = FileField()
     self.assertEqual({
         'type': 'string',
     }, field.to_dict())