예제 #1
0
 def test_parse_as_slug(self):
     app = Webapp.objects.get(pk=337141)
     into = {}
     field = SlugOrPrimaryKeyRelatedField(queryset=Webapp.objects.all(),
                                          slug_field='app_slug')
     field.field_from_native({'addon': app.app_slug}, None, 'addon', into)
     eq_(into, {'addon': app})
예제 #2
0
 def test_parse_as_slugs(self):
     c1 = Category.objects.create(name="delicious", slug="foo", type=amo.ADDON_WEBAPP)
     c2 = Category.objects.create(name="scrumptious", slug="baz", type=amo.ADDON_WEBAPP)
     into = {}
     field = SlugOrPrimaryKeyRelatedField(queryset=Category.objects.all(), many=True)
     field.field_from_native({"categories": [c1.slug, c2.slug]}, None, "categories", into)
     eq_(into, {"categories": [c1, c2]})
예제 #3
0
 def test_parse_as_slug(self):
     app = Webapp.objects.get(pk=337141)
     into = {}
     field = SlugOrPrimaryKeyRelatedField(queryset=Webapp.objects.all(),
                                          slug_field='app_slug')
     field.field_from_native({'addon': app.app_slug}, None, 'addon', into)
     eq_(into, {'addon': app})
예제 #4
0
 def test_parse_as_pks_many(self):
     app2 = app_factory()
     into = {}
     field = SlugOrPrimaryKeyRelatedField(queryset=Webapp.objects.all(),
                                          many=True)
     field.field_from_native({'apps': [self.app.pk, app2.pk]}, None, 'apps',
                             into)
     eq_(into, {'apps': [self.app, app2]})
예제 #5
0
 def test_parse_as_slugs_many(self):
     app2 = amo.tests.app_factory(app_slug='foo')
     into = {}
     field = SlugOrPrimaryKeyRelatedField(queryset=Webapp.objects.all(),
                                          slug_field='app_slug', many=True)
     field.field_from_native({'apps': [self.app.app_slug, app2.app_slug]},
                             None, 'apps', into)
     eq_(into, {'apps': [self.app, app2]})
예제 #6
0
 def test_parse_as_pks_many(self):
     app2 = amo.tests.app_factory()
     into = {}
     field = SlugOrPrimaryKeyRelatedField(queryset=Webapp.objects.all(),
                                          many=True)
     field.field_from_native({'apps': [self.app.pk, app2.pk]}, None,
                              'apps', into)
     eq_(into, {'apps': [self.app, app2]})
예제 #7
0
 def test_parse_as_slugs_many(self):
     app2 = app_factory(app_slug='foo')
     into = {}
     field = SlugOrPrimaryKeyRelatedField(queryset=Webapp.objects.all(),
                                          slug_field='app_slug',
                                          many=True)
     field.field_from_native({'apps': [self.app.app_slug, app2.app_slug]},
                             None, 'apps', into)
     eq_(into, {'apps': [self.app, app2]})
예제 #8
0
 def test_parse_as_slugs(self):
     c1 = Category.objects.create(name='delicious', slug='foo',
                                  type=amo.ADDON_WEBAPP)
     c2 = Category.objects.create(name='scrumptious', slug='baz',
                                  type=amo.ADDON_WEBAPP)
     into = {}
     field = SlugOrPrimaryKeyRelatedField(queryset=Category.objects.all(),
                                          many=True)
     field.field_from_native({'categories': [c1.slug, c2.slug]}, None,
                             'categories', into)
     eq_(into, {'categories': [c1, c2]})
예제 #9
0
 def test_parse_as_slugs(self):
     c1 = Category.objects.create(name='delicious',
                                  slug='foo',
                                  type=amo.ADDON_WEBAPP)
     c2 = Category.objects.create(name='scrumptious',
                                  slug='baz',
                                  type=amo.ADDON_WEBAPP)
     into = {}
     field = SlugOrPrimaryKeyRelatedField(queryset=Category.objects.all(),
                                          many=True)
     field.field_from_native({'categories': [c1.slug, c2.slug]}, None,
                             'categories', into)
     eq_(into, {'categories': [c1, c2]})
예제 #10
0
 def test_parse_as_pk(self):
     into = {}
     field = SlugOrPrimaryKeyRelatedField(queryset=Webapp.objects.all())
     field.field_from_native({'addon': self.app.pk}, None, 'addon', into)
     eq_(into, {'addon': self.app})
예제 #11
0
 def test_parse_as_pk(self):
     into = {}
     field = SlugOrPrimaryKeyRelatedField(queryset=Webapp.objects.all())
     field.field_from_native({'addon': self.app.pk}, None, 'addon', into)
     eq_(into, {'addon': self.app})
예제 #12
0
 def test_parse_as_pk(self):
     app = Webapp.objects.get(pk=337141)
     into = {}
     field = SlugOrPrimaryKeyRelatedField(queryset=Webapp.objects.all())
     field.field_from_native({"addon": 337141}, None, "addon", into)
     eq_(into, {"addon": app})