Award correct points for langpacks and dicts

This commit is contained in:
Andreas Wagner 2018-10-15 18:09:29 +02:00
Родитель 0315f6f9a9
Коммит a27663cf1b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: A225F31689BE06A1
2 изменённых файлов: 90 добавлений и 3 удалений

Просмотреть файл

@ -430,7 +430,14 @@ class ReviewerScore(ModelBase):
'No such version/auto approval summary when determining '
'event type to award points: %r', exception)
weight = 0
if weight > amo.POST_REVIEW_WEIGHT_HIGHEST_RISK:
if addon.type == amo.ADDON_DICT:
reviewed_score_name = 'REVIEWED_DICT_FULL'
elif addon.type in [amo.ADDON_LPAPP, amo.ADDON_LPADDON]:
reviewed_score_name = 'REVIEWED_LP_FULL'
elif addon.type == amo.ADDON_SEARCH:
reviewed_score_name = 'REVIEWED_SEARCH_FULL'
elif weight > amo.POST_REVIEW_WEIGHT_HIGHEST_RISK:
reviewed_score_name = 'REVIEWED_EXTENSION_HIGHEST_RISK'
elif weight > amo.POST_REVIEW_WEIGHT_HIGH_RISK:
reviewed_score_name = 'REVIEWED_EXTENSION_HIGH_RISK'
@ -490,7 +497,7 @@ class ReviewerScore(ModelBase):
# As a hack, we set 'post_review' to True.
if (version and
version.is_webextension and
addon.type == amo.ADDON_EXTENSION):
addon.type in amo.GROUP_TYPE_ADDON):
post_review = True
user_log.info(

Просмотреть файл

@ -586,7 +586,7 @@ class TestReviewerScore(TestCase):
amo.REVIEWED_EXTENSION_MEDIUM_RISK]
assert score.version == self.addon.current_version
def test_award_points_disabled_auto_approval(self):
def test_award_points_extension_disabled_autoapproval(self):
self.version = version_factory(
addon=self.addon, version='1.1', file_kw={
'status': amo.STATUS_AWAITING_REVIEW,
@ -603,6 +603,86 @@ class TestReviewerScore(TestCase):
amo.REVIEWED_EXTENSION_MEDIUM_RISK]
assert score.version == self.addon.current_version
def test_award_points_langpack_post_review(self):
search_provider = amo.tests.addon_factory(
status=amo.STATUS_PUBLIC, type=amo.ADDON_LPAPP)
self.version = version_factory(
addon=search_provider, version='1.1', file_kw={
'status': amo.STATUS_PUBLIC,
'is_webextension': True})
AutoApprovalSummary.objects.create(
version=search_provider.current_version,
verdict=amo.AUTO_APPROVED,
weight=101)
ReviewerScore.award_points(
self.user, search_provider, search_provider.status,
version=search_provider.current_version,
post_review=True, content_review=False)
score = ReviewerScore.objects.get(user=self.user)
assert score.score == amo.REVIEWED_SCORES[
amo.REVIEWED_LP_FULL]
assert score.version == search_provider.current_version
def test_award_points_langpack_disabled_auto_approval(self):
search_provider = amo.tests.addon_factory(
status=amo.STATUS_NOMINATED, type=amo.ADDON_LPAPP)
self.version = version_factory(
addon=search_provider, version='1.1', file_kw={
'status': amo.STATUS_AWAITING_REVIEW,
'is_webextension': True})
AutoApprovalSummary.objects.create(
version=search_provider.current_version,
verdict=amo.NOT_AUTO_APPROVED,
weight=101)
ReviewerScore.award_points(
self.user, search_provider, search_provider.status,
version=search_provider.current_version,
post_review=False, content_review=False)
score = ReviewerScore.objects.get(user=self.user)
assert score.score == amo.REVIEWED_SCORES[
amo.REVIEWED_LP_FULL]
assert score.version == search_provider.current_version
def test_award_points_dict_post_review(self):
dictionary = amo.tests.addon_factory(
status=amo.STATUS_PUBLIC, type=amo.ADDON_DICT)
self.version = version_factory(
addon=dictionary, version='1.1', file_kw={
'status': amo.STATUS_PUBLIC,
'is_webextension': True})
AutoApprovalSummary.objects.create(
version=dictionary.current_version,
verdict=amo.AUTO_APPROVED,
weight=101)
ReviewerScore.award_points(
self.user, dictionary, dictionary.status,
version=dictionary.current_version,
post_review=True, content_review=False)
score = ReviewerScore.objects.get(user=self.user)
assert score.score == amo.REVIEWED_SCORES[
amo.REVIEWED_DICT_FULL]
assert score.version == dictionary.current_version
def test_award_points_dict_disabled_auto_approval(self):
dictionary = amo.tests.addon_factory(
status=amo.STATUS_NOMINATED, type=amo.ADDON_DICT)
self.version = version_factory(
addon=dictionary, version='1.1', file_kw={
'status': amo.STATUS_AWAITING_REVIEW,
'is_webextension': True})
AutoApprovalSummary.objects.create(
version=dictionary.current_version,
verdict=amo.NOT_AUTO_APPROVED,
weight=101)
ReviewerScore.award_points(
self.user, dictionary, dictionary.status,
version=dictionary.current_version,
post_review=False, content_review=False)
score = ReviewerScore.objects.get(user=self.user)
assert score.score == amo.REVIEWED_SCORES[
amo.REVIEWED_DICT_FULL]
assert score.version == dictionary.current_version
def test_award_moderation_points(self):
ReviewerScore.award_moderation_points(self.user, self.addon, 1)
score = ReviewerScore.objects.all()[0]