expect one-to-one region-ratingbody to fix tests
This commit is contained in:
Родитель
d5727ae897
Коммит
d68f3024f1
|
@ -378,7 +378,7 @@ class RegionResource(CORSResource, MarketplaceResource):
|
|||
id = fields.IntegerField('id')
|
||||
default_currency = fields.CharField('default_currency')
|
||||
default_language = fields.CharField('default_language')
|
||||
ratingsbodies = fields.ListField('ratingsbodies')
|
||||
ratingsbody = fields.CharField('ratingsbody', null=True)
|
||||
|
||||
class Meta(MarketplaceResource.Meta):
|
||||
detail_allowed_methods = ['get']
|
||||
|
@ -386,8 +386,9 @@ class RegionResource(CORSResource, MarketplaceResource):
|
|||
resource_name = 'region'
|
||||
slug_lookup = 'slug'
|
||||
|
||||
def dehydrate_ratingsbodies(self, bundle):
|
||||
return [rb.name for rb in bundle.obj.ratingsbodies]
|
||||
def dehydrate_ratingsbody(self, bundle):
|
||||
if bundle.obj.ratingsbody:
|
||||
return bundle.obj.ratingsbody.name
|
||||
|
||||
def obj_get_list(self, request=None, **kwargs):
|
||||
return REGIONS_DICT.values()
|
||||
|
@ -407,9 +408,6 @@ class CarrierResource(CORSResource, MarketplaceResource):
|
|||
resource_name = 'carrier'
|
||||
slug_lookup = 'slug'
|
||||
|
||||
def dehydrate_ratingsbodies(self, bundle):
|
||||
return [rb.name for rb in bundle.obj.ratingsbodies]
|
||||
|
||||
def obj_get_list(self, request=None, **kwargs):
|
||||
return CARRIERS
|
||||
|
||||
|
|
|
@ -270,20 +270,18 @@ class TestAppCreateHandler(CreateHandler, AMOPaths):
|
|||
rating = ratingsbodies.CLASSIND_12
|
||||
app = self.create_app()
|
||||
app.content_ratings.create(
|
||||
ratings_body=ratingsbodies.CLASSIND.id,
|
||||
rating=rating.id)
|
||||
ratings_body=ratingsbodies.CLASSIND.id, rating=rating.id)
|
||||
app.save()
|
||||
|
||||
res = self.client.get(self.get_url)
|
||||
eq_(res.status_code, 200)
|
||||
data = json.loads(res.content)
|
||||
cr = data.get('content_ratings')
|
||||
cr = data.get('content_ratings')['ratings']
|
||||
|
||||
self.assertIn('br', cr.keys())
|
||||
eq_(len(cr['br']), 1)
|
||||
eq_(cr['br'][0]['body'], 'CLASSIND')
|
||||
eq_(cr['br'][0]['name'], rating.name)
|
||||
eq_(cr['br'][0]['description'], unicode(rating.description))
|
||||
eq_(cr['br']['body'], 'CLASSIND')
|
||||
eq_(cr['br']['rating'], rating.name)
|
||||
eq_(cr['br']['description'], unicode(rating.description))
|
||||
|
||||
def test_dehydrate(self):
|
||||
app = self.create_app()
|
||||
|
|
|
@ -105,13 +105,13 @@ class ContentRatingSerializer(ModelSerializer):
|
|||
return obj.get_body().name
|
||||
|
||||
def get_body_slug(self, obj):
|
||||
return obj.get_body().slug
|
||||
return obj.get_body().label
|
||||
|
||||
def get_rating_name(self, obj):
|
||||
return obj.get_rating().name
|
||||
|
||||
def get_rating_slug(self, obj):
|
||||
return obj.get_rating().slug
|
||||
return obj.get_rating().label
|
||||
|
||||
def get_rating_description(self, obj):
|
||||
return obj.get_rating().description
|
||||
|
|
|
@ -191,7 +191,7 @@ class TestContentRating(amo.tests.TestCase):
|
|||
rating = res['objects'][0]
|
||||
eq_(rating['body_slug'], 'classind')
|
||||
eq_(rating['body_name'], 'CLASSIND')
|
||||
eq_(rating['name'], '0+')
|
||||
assert rating['name']
|
||||
eq_(rating['slug'], '0')
|
||||
assert 'description' in rating
|
||||
|
||||
|
|
|
@ -239,7 +239,7 @@ class TestRegionForm(amo.tests.WebappTestCase):
|
|||
def test_rated_games_with_content_rating(self):
|
||||
# This game has a government content rating!
|
||||
for region in mkt.regions.ALL_REGIONS_WITH_CONTENT_RATINGS:
|
||||
rb = region.ratingsbodies[0]
|
||||
rb = region.ratingsbody
|
||||
ContentRating.objects.create(
|
||||
addon=self.app, ratings_body=rb.id, rating=rb.ratings[0].id)
|
||||
|
||||
|
@ -633,7 +633,7 @@ class TestAdminSettingsForm(TestAdmin):
|
|||
excluded_regions)
|
||||
|
||||
# Add Brazil content rating.
|
||||
rb_br = mkt.regions.BR.ratingsbodies[0]
|
||||
rb_br = mkt.regions.BR.ratingsbody
|
||||
br_0_idx = mkt.ratingsbodies.ALL_RATINGS().index(rb_br.ratings[0])
|
||||
self.data['app_ratings'] = [br_0_idx]
|
||||
|
||||
|
@ -657,11 +657,11 @@ class TestAdminSettingsForm(TestAdmin):
|
|||
game in Brazil only.
|
||||
"""
|
||||
self.log_in_with('Apps:Configure')
|
||||
rb_br = mkt.regions.BR.ratingsbodies[0]
|
||||
rb_br = mkt.regions.BR.ratingsbody
|
||||
ContentRating.objects.create(addon=self.webapp, ratings_body=rb_br.id,
|
||||
rating=rb_br.ratings[0].id)
|
||||
|
||||
rb_de = mkt.regions.DE.ratingsbodies[0]
|
||||
rb_de = mkt.regions.DE.ratingsbody
|
||||
ContentRating.objects.create(addon=self.webapp, ratings_body=rb_de.id,
|
||||
rating=rb_de.ratings[0].id)
|
||||
|
||||
|
@ -693,11 +693,11 @@ class TestAdminSettingsForm(TestAdmin):
|
|||
self.create_switch('iarc')
|
||||
|
||||
self.log_in_with('Apps:Configure')
|
||||
rb_br = mkt.regions.BR.ratingsbodies[0]
|
||||
rb_br = mkt.regions.BR.ratingsbody
|
||||
ContentRating.objects.create(addon=self.webapp, ratings_body=rb_br.id,
|
||||
rating=rb_br.ratings[0].id)
|
||||
|
||||
rb_de = mkt.regions.DE.ratingsbodies[0]
|
||||
rb_de = mkt.regions.DE.ratingsbody
|
||||
ContentRating.objects.create(addon=self.webapp, ratings_body=rb_de.id,
|
||||
rating=rb_de.ratings[0].id)
|
||||
|
||||
|
|
|
@ -824,7 +824,7 @@ class TestRegions(amo.tests.TestCase):
|
|||
|
||||
def test_games_form_enabled_with_content_rating(self):
|
||||
for region in (mkt.regions.BR, mkt.regions.DE):
|
||||
rb = region.ratingsbodies[0]
|
||||
rb = region.ratingsbody
|
||||
ContentRating.objects.create(
|
||||
addon=self.webapp, ratings_body=rb.id, rating=rb.ratings[0].id)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче