diff --git a/api/test/factory/models/audio.py b/api/test/factory/models/audio.py index 74f008a9d1e..b5a096082af 100644 --- a/api/test/factory/models/audio.py +++ b/api/test/factory/models/audio.py @@ -3,7 +3,11 @@ from api.models.audio import Audio, AudioAddOn, AudioReport, SensitiveAudio from test.factory.faker import Faker -from test.factory.models.media import IdentifierFactory, MediaFactory, MediaReportFactory +from test.factory.models.media import ( + IdentifierFactory, + MediaFactory, + MediaReportFactory, +) class SensitiveAudioFactory(DjangoModelFactory): diff --git a/api/test/factory/models/oauth2.py b/api/test/factory/models/oauth2.py index 7d883802c0b..28f5eac9e39 100644 --- a/api/test/factory/models/oauth2.py +++ b/api/test/factory/models/oauth2.py @@ -1,5 +1,5 @@ -from django.utils import timezone from django.contrib.auth import get_user_model +from django.utils import timezone import factory from factory.django import DjangoModelFactory diff --git a/api/test/unit/management/commands/test_backfillmoderationdecision.py b/api/test/unit/management/commands/test_backfillmoderationdecision.py index e92a26692f4..f609f1aef2c 100644 --- a/api/test/unit/management/commands/test_backfillmoderationdecision.py +++ b/api/test/unit/management/commands/test_backfillmoderationdecision.py @@ -1,10 +1,19 @@ from io import StringIO -import pytest from django.core.management import call_command -from api.models import AudioDecision, ImageDecision -from api.models import DMCA, MATURE, OTHER, MATURE_FILTERED, NO_ACTION, DEINDEXED +import pytest + +from api.models import ( + DEINDEXED, + DMCA, + MATURE, + MATURE_FILTERED, + NO_ACTION, + OTHER, + AudioDecision, + ImageDecision, +) from test.factory.models.audio import AudioReportFactory from test.factory.models.image import ImageReportFactory from test.factory.models.oauth2 import UserFactory @@ -31,6 +40,7 @@ def make_reports(media_type, reason: str, status: str, count: int = 1): else: ImageReportFactory.create_batch(count, status=status, reason=reason) + @pytest.mark.parametrize( ("reason", "status", "expected_action"), ( @@ -43,17 +53,19 @@ def make_reports(media_type, reason: str, status: str, count: int = 1): (MATURE, DEINDEXED, "deindexed_sensitive"), (DMCA, DEINDEXED, "deindexed_copyright"), (OTHER, DEINDEXED, "deindexed_sensitive"), - ) + ), ) @pytest.mark.parametrize(("media_type"), ("image", "audio")) @pytest.mark.django_db -def test_create_moderation_decision_for_reports(media_type, reason, status, expected_action): +def test_create_moderation_decision_for_reports( + media_type, reason, status, expected_action +): username = "opener" UserFactory.create(username=username) make_reports(media_type=media_type, reason=reason, status=status) - out , err = call_cmd(dry_run=False, media_type=media_type, moderator=username) + out, err = call_cmd(dry_run=False, media_type=media_type, moderator=username) MediaDecision = ImageDecision if media_type == "image" else AudioDecision assert MediaDecision.objects.count() == 1 @@ -69,4 +81,4 @@ def test_catch_user_exception(): make_reports(media_type="image", reason=MATURE, status=MATURE_FILTERED) _, err = call_cmd(dry_run=False, moderator="nonexistent") - assert "User 'nonexistent' not found." in err \ No newline at end of file + assert "User 'nonexistent' not found." in err