-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
flag correct versions for a developer appeal
- Loading branch information
Showing
2 changed files
with
67 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,9 +136,14 @@ def test_build_report_payload(self): | |
def test_report(self): | ||
self._test_report(self._create_dummy_target()) | ||
|
||
def _test_appeal(self, appealer, cinder_instance=None): | ||
fake_decision_id = 'decision-id-to-appeal-666' | ||
cinder_instance = cinder_instance or self.CinderClass( | ||
def _test_appeal( | ||
self, | ||
appealer, | ||
*, | ||
cinder_entity_instance=None, | ||
appealed_decision_id='decision-id-to-appeal-666', | ||
): | ||
cinder_entity_instance = cinder_entity_instance or self.CinderClass( | ||
self._create_dummy_target() | ||
) | ||
|
||
|
@@ -149,8 +154,8 @@ def _test_appeal(self, appealer, cinder_instance=None): | |
status=201, | ||
) | ||
assert ( | ||
cinder_instance.appeal( | ||
decision_cinder_id=fake_decision_id, | ||
cinder_entity_instance.appeal( | ||
decision_cinder_id=appealed_decision_id, | ||
appeal_text='reason', | ||
appealer=appealer, | ||
) | ||
|
@@ -163,8 +168,8 @@ def _test_appeal(self, appealer, cinder_instance=None): | |
status=400, | ||
) | ||
with self.assertRaises(ConnectionError): | ||
cinder_instance.appeal( | ||
decision_cinder_id=fake_decision_id, | ||
cinder_entity_instance.appeal( | ||
decision_cinder_id=appealed_decision_id, | ||
appeal_text='reason', | ||
appealer=appealer, | ||
) | ||
|
@@ -1204,7 +1209,8 @@ def test_report_with_version(self): | |
def test_appeal_anonymous(self): | ||
addon = self._create_dummy_target() | ||
self._test_appeal( | ||
CinderUnauthenticatedReporter('itsme', '[email protected]'), self.CinderClass(addon) | ||
CinderUnauthenticatedReporter('itsme', '[email protected]'), | ||
cinder_entity_instance=self.CinderClass(addon), | ||
) | ||
assert ( | ||
addon.current_version.needshumanreview_set.get().reason | ||
|
@@ -1214,23 +1220,55 @@ def test_appeal_anonymous(self): | |
|
||
def test_appeal_logged_in(self): | ||
addon = self._create_dummy_target() | ||
self._test_appeal(CinderUser(user_factory()), self.CinderClass(addon)) | ||
self._test_appeal( | ||
CinderUser(user_factory()), cinder_entity_instance=self.CinderClass(addon) | ||
) | ||
assert ( | ||
addon.current_version.needshumanreview_set.get().reason | ||
== NeedsHumanReview.REASONS.ADDON_REVIEW_APPEAL | ||
) | ||
assert addon.current_version.reload().due_date | ||
|
||
def test_appeal_specific_version(self): | ||
def test_appeal_specific_version_from_report(self): | ||
# version_string is set for reporter appeals on reports that specified a version | ||
addon = self._create_dummy_target() | ||
other_version = version_factory( | ||
addon=addon, | ||
channel=amo.CHANNEL_UNLISTED, | ||
file_kw={'status': amo.STATUS_AWAITING_REVIEW}, | ||
) | ||
self._test_appeal( | ||
CinderUser(user_factory()), | ||
cinder_entity_instance=self.CinderClass( | ||
addon, version_string=other_version.version | ||
), | ||
) | ||
assert not addon.current_version.needshumanreview_set.exists() | ||
assert ( | ||
other_version.needshumanreview_set.get().reason | ||
== NeedsHumanReview.REASONS.ADDON_REVIEW_APPEAL | ||
) | ||
assert not addon.current_version.reload().due_date | ||
assert other_version.reload().due_date | ||
|
||
def test_appeal_specific_version_from_action(self): | ||
# for developer appeals we should use the versions that were affected | ||
addon = self._create_dummy_target() | ||
other_version = version_factory( | ||
addon=addon, | ||
channel=amo.CHANNEL_UNLISTED, | ||
file_kw={'status': amo.STATUS_AWAITING_REVIEW}, | ||
) | ||
decision = ContentDecision.objects.create( | ||
action=DECISION_ACTIONS.AMO_DISABLE_ADDON, cinder_id='some_id', addon=addon | ||
) | ||
ActivityLog.objects.create( | ||
amo.LOG.FORCE_DISABLE, addon, other_version, decision, user=user_factory() | ||
) | ||
self._test_appeal( | ||
CinderUser(user_factory()), | ||
self.CinderClass(addon, version_string=other_version.version), | ||
cinder_entity_instance=self.CinderClass(addon, version_string=None), | ||
appealed_decision_id=decision.cinder_id, | ||
) | ||
assert not addon.current_version.needshumanreview_set.exists() | ||
assert ( | ||
|
@@ -1248,7 +1286,7 @@ def test_appeal_no_current_version(self): | |
assert not addon.current_version | ||
self._test_appeal( | ||
CinderUser(user_factory()), | ||
self.CinderClass(addon), | ||
cinder_entity_instance=self.CinderClass(addon), | ||
) | ||
assert ( | ||
version.needshumanreview_set.get().reason | ||
|
@@ -1263,7 +1301,9 @@ def test_appeal_waffle_switch_off(self): | |
# etc since the waffle switch is off. So we're back to the same number of | ||
# queries made by the reports that go to Cinder. | ||
self.expected_queries_for_report = TestCinderAddon.expected_queries_for_report | ||
self._test_appeal(CinderUser(user_factory()), self.CinderClass(addon)) | ||
self._test_appeal( | ||
CinderUser(user_factory()), cinder_entity_instance=self.CinderClass(addon) | ||
) | ||
assert addon.current_version.needshumanreview_set.count() == 0 | ||
|
||
def test_report_with_ongoing_appeal(self): | ||
|