예제 #1
0
    def test_render_as_slugs_many(self):
        obj = Mock()
        obj.attached = [self.app]

        field = SlugOrPrimaryKeyRelatedField(render_as='slug',
                                             slug_field='app_slug', many=True)
        eq_(field.field_to_native(obj, 'attached'), [self.app.app_slug])
예제 #2
0
    def test_render_as_slug(self):
        obj = Mock()
        obj.attached = self.app

        field = SlugOrPrimaryKeyRelatedField(render_as='slug',
                                             slug_field='app_slug')
        eq_(field.field_to_native(obj, 'attached'), self.app.app_slug)
예제 #3
0
    def test_render_as_slug(self):
        obj = Mock()
        obj.attached = self.app

        field = SlugOrPrimaryKeyRelatedField(render_as='slug',
                                             slug_field='app_slug')
        eq_(field.field_to_native(obj, 'attached'), self.app.app_slug)
예제 #4
0
    def test_render_as_slugs_many(self):
        obj = Mock()
        obj.attached = [self.app]

        field = SlugOrPrimaryKeyRelatedField(render_as='slug',
                                             slug_field='app_slug',
                                             many=True)
        eq_(field.field_to_native(obj, 'attached'), [self.app.app_slug])
예제 #5
0
 def test_render_as_pks(self):
     app = Webapp.objects.get(pk=337141)
     c1 = Category.objects.create(name="delicious", slug="foo", type=amo.ADDON_WEBAPP)
     c2 = Category.objects.create(name="scrumptious", slug="baz", type=amo.ADDON_WEBAPP)
     AddonCategory.objects.create(addon=app, category=c1)
     AddonCategory.objects.create(addon=app, category=c2)
     field = SlugOrPrimaryKeyRelatedField(queryset=Category.objects.all(), many=True)
     eq_(field.field_to_native(app, "categories"), [c1.pk, c2.pk])
예제 #6
0
 def test_render_as_slugs(self):
     app = Webapp.objects.get(pk=337141)
     c1 = Category.objects.create(name='delicious', slug='foo',
                                  type=amo.ADDON_WEBAPP)
     c2 = Category.objects.create(name='scrumptious', slug='baz',
                                  type=amo.ADDON_WEBAPP)
     AddonCategory.objects.create(addon=app, category=c1)
     AddonCategory.objects.create(addon=app, category=c2)
     field = SlugOrPrimaryKeyRelatedField(queryset=Category.objects.all(),
                                          render_as='slug',
                                          slug_field='slug',
                                          many=True)
     eq_(field.field_to_native(app, 'categories'), [c1.slug, c2.slug])
예제 #7
0
 def test_render_as_pks(self):
     app = Webapp.objects.get(pk=337141)
     c1 = Category.objects.create(name='delicious',
                                  slug='foo',
                                  type=amo.ADDON_WEBAPP)
     c2 = Category.objects.create(name='scrumptious',
                                  slug='baz',
                                  type=amo.ADDON_WEBAPP)
     AddonCategory.objects.create(addon=app, category=c1)
     AddonCategory.objects.create(addon=app, category=c2)
     field = SlugOrPrimaryKeyRelatedField(queryset=Category.objects.all(),
                                          many=True)
     eq_(field.field_to_native(app, 'categories'), [c1.pk, c2.pk])
예제 #8
0
 def test_render_as_slug(self):
     v = Version.objects.get(pk=1268829)
     field = SlugOrPrimaryKeyRelatedField(queryset=Webapp.objects.all(),
                                          render_as='slug',
                                          slug_field='app_slug')
     eq_(field.field_to_native(v, 'addon'), v.addon.app_slug)
예제 #9
0
 def test_render_as_pk(self):
     v = Version.objects.get(pk=1268829)
     field = SlugOrPrimaryKeyRelatedField(queryset=Webapp.objects.all())
     eq_(field.field_to_native(v, 'addon'), v.addon.pk)
예제 #10
0
    def test_render_as_pks_many(self):
        obj = Mock()
        obj.attached = [self.app]

        field = SlugOrPrimaryKeyRelatedField(many=True)
        eq_(field.field_to_native(obj, 'attached'), [self.app.pk])
예제 #11
0
    def test_render_as_pk(self):
        obj = Mock()
        obj.attached = self.app

        field = SlugOrPrimaryKeyRelatedField()
        eq_(field.field_to_native(obj, 'attached'), self.app.pk)
예제 #12
0
 def test_render_as_slug(self):
     v = Version.objects.get(pk=1268829)
     field = SlugOrPrimaryKeyRelatedField(queryset=Webapp.objects.all(),
                                          render_as='slug',
                                          slug_field='app_slug')
     eq_(field.field_to_native(v, 'addon'), v.addon.app_slug)
예제 #13
0
 def test_render_as_pk(self):
     v = Version.objects.get(pk=1268829)
     field = SlugOrPrimaryKeyRelatedField(queryset=Webapp.objects.all())
     eq_(field.field_to_native(v, 'addon'), v.addon.pk)
예제 #14
0
    def test_render_as_pks_many(self):
        obj = Mock()
        obj.attached = [self.app]

        field = SlugOrPrimaryKeyRelatedField(many=True)
        eq_(field.field_to_native(obj, 'attached'), [self.app.pk])
예제 #15
0
    def test_render_as_pk(self):
        obj = Mock()
        obj.attached = self.app

        field = SlugOrPrimaryKeyRelatedField()
        eq_(field.field_to_native(obj, 'attached'), self.app.pk)