Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
krysal committed May 31, 2024
1 parent c6c6d4b commit 3daf454
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
6 changes: 5 additions & 1 deletion api/test/factory/models/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion api/test/factory/models/oauth2.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"),
(
Expand All @@ -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
Expand All @@ -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
assert "User 'nonexistent' not found." in err

0 comments on commit 3daf454

Please sign in to comment.