Skip to content

Commit

Permalink
Use specific waffle switch to gate reviewer tools cinder integration (#…
Browse files Browse the repository at this point in the history
…21878)

* Use specific waffle switch to gate reviewer tools cinder integration

This allows us to enable cinder full integration while not showing
reports in reviewer tools.
  • Loading branch information
diox committed Feb 16, 2024
1 parent 24629f8 commit 2475109
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/olympia/reviewers/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,10 @@ def __init__(self, *args, **kw):
.unresolved()
.resolvable_in_reviewer_tools()
.prefetch_related('abusereport_set', 'appealed_jobs')
if waffle.switch_is_active('enable-cinder-reporting')
if (
waffle.switch_is_active('enable-cinder-reviewer-tools-integration')
and waffle.switch_is_active('enable-cinder-reporting')
)
else CinderJob.objects.none()
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Generated by Django 4.2.9 on 2024-02-16 12:01

from django.db import migrations

from olympia.core.db.migrations import CreateWaffleSwitch


class Migration(migrations.Migration):
dependencies = [
("reviewers", "0033_reviewactionreason_cinder_policy"),
]

operations = [
CreateWaffleSwitch('enable-cinder-reviewer-tools-integration')
]
19 changes: 18 additions & 1 deletion src/olympia/reviewers/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,9 +841,26 @@ def test_resolve_cinder_jobs_choices(self):
),
)

# No switch enabled, can't resolve jobs.
assert len(self.get_form().fields['resolve_cinder_jobs'].choices) == 0

with override_switch('enable-cinder-reporting', active=True):
# Only one of the switches enabled, still can't resolve jobs.
with (
override_switch('enable-cinder-reviewer-tools-integration', active=True),
):
assert len(self.get_form().fields['resolve_cinder_jobs'].choices) == 0

# Only one of the switches enabled, still can't resolve jobs.
with (
override_switch('enable-cinder-reporting', active=True),
):
assert len(self.get_form().fields['resolve_cinder_jobs'].choices) == 0

# Both switches enabled, we can see jobs to resolve.
with (
override_switch('enable-cinder-reviewer-tools-integration', active=True),
override_switch('enable-cinder-reporting', active=True),
):
form = self.get_form()
choices = form.fields['resolve_cinder_jobs'].choices
qs_list = list(choices.queryset)
Expand Down
7 changes: 6 additions & 1 deletion src/olympia/reviewers/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5542,12 +5542,16 @@ def test_resolve_abuse_reports_checkbox(self):
response = self.client.get(self.url)
self.assertNotContains(response, 'Show 1 reports')

with override_switch('enable-cinder-reporting', active=True):
with (
override_switch('enable-cinder-reporting', active=True),
override_switch('enable-cinder-reviewer-tools-integration', active=True),
):
response = self.client.get(self.url)
self.assertContains(response, 'Show 1 reports')
self.assertContains(response, 'Its baaaad')

@override_switch('enable-cinder-reporting', active=True)
@override_switch('enable-cinder-reviewer-tools-integration', active=True)
@mock.patch('olympia.reviewers.utils.resolve_job_in_cinder.delay')
def test_abuse_reports_resolved_as_disable_addon_with_disable_action(
self, mock_resolve_task
Expand Down Expand Up @@ -5591,6 +5595,7 @@ def test_abuse_reports_resolved_as_disable_addon_with_disable_action(
)

@override_switch('enable-cinder-reporting', active=True)
@override_switch('enable-cinder-reviewer-tools-integration', active=True)
@mock.patch('olympia.reviewers.utils.resolve_job_in_cinder.delay')
@mock.patch('olympia.reviewers.utils.sign_file')
def test_abuse_reports_resolved_as_approve_with_approve_latest_version_action(
Expand Down

0 comments on commit 2475109

Please sign in to comment.