Пример #1
0
    def test_render_as_pks_many(self):
        obj = Mock()
        obj.attached = [self.app]

        field = SlugOrPrimaryKeyRelatedField(many=True, read_only=True)
        field.bind('attached', None)
        eq_(field.to_representation(field.get_attribute(obj)), [self.app.pk])
Пример #2
0
    def test_render_as_pks_many(self):
        obj = Mock()
        obj.attached = [self.app]

        field = SlugOrPrimaryKeyRelatedField(many=True, read_only=True)
        field.bind('attached', None)
        eq_(field.to_representation(field.get_attribute(obj)), [self.app.pk])
Пример #3
0
    def test_render_as_slug(self):
        obj = Mock()
        obj.attached = self.app

        field = SlugOrPrimaryKeyRelatedField(render_as='slug',
                                             slug_field='app_slug',
                                             read_only=True)
        field.bind('attached', None)
        eq_(field.to_representation(field.get_attribute(obj)),
            self.app.app_slug)
Пример #4
0
    def test_render_as_slug(self):
        obj = Mock()
        obj.attached = self.app

        field = SlugOrPrimaryKeyRelatedField(render_as='slug',
                                             slug_field='app_slug',
                                             read_only=True)
        field.bind('attached', None)
        eq_(field.to_representation(field.get_attribute(obj)),
            self.app.app_slug)