Skip to content

Commit

Permalink
apps/moderatorfeedback: add another merge migration (after change of …
Browse files Browse the repository at this point in the history
…TimeStampedModel fields) to make sure all migrations are run
  • Loading branch information
fuzzylogic2000 authored and philli-m committed Jun 19, 2023
1 parent b08b222 commit 25b4c17
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Generated by Django 3.2.18 on 2023-03-07 16:17

from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):

dependencies = [
("a4_candy_classifications", "0008_make_classifications_char_field"),
]

operations = [
migrations.AlterField(
model_name="aiclassification",
name="created",
field=models.DateTimeField(
default=django.utils.timezone.now,
editable=False,
verbose_name="Created",
),
),
migrations.AlterField(
model_name="aiclassification",
name="modified",
field=models.DateTimeField(
blank=True, editable=False, null=True, verbose_name="Modified"
),
),
migrations.AlterField(
model_name="userclassification",
name="created",
field=models.DateTimeField(
default=django.utils.timezone.now,
editable=False,
verbose_name="Created",
),
),
migrations.AlterField(
model_name="userclassification",
name="modified",
field=models.DateTimeField(
blank=True, editable=False, null=True, verbose_name="Modified"
),
),
]
13 changes: 13 additions & 0 deletions apps/moderatorfeedback/migrations/0005_merge_20230307_1614.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Generated by Django 3.2.18 on 2023-03-07 15:14

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("a4_candy_moderatorfeedback", "0004_merge_20230301_1649"),
("a4_candy_moderatorfeedback", "0004_verbose_name_created_modified"),
]

operations = []
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 3.2.18 on 2023-03-07 16:17

from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):

dependencies = [
("a4_candy_moderatorfeedback", "0005_merge_20230307_1614"),
]

operations = [
migrations.AlterField(
model_name="moderatorcommentstatement",
name="created",
field=models.DateTimeField(
default=django.utils.timezone.now,
editable=False,
verbose_name="Created",
),
),
migrations.AlterField(
model_name="moderatorcommentstatement",
name="modified",
field=models.DateTimeField(
blank=True, editable=False, null=True, verbose_name="Modified"
),
),
]
121 changes: 79 additions & 42 deletions tests/classifications/test_classification_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,38 @@


@pytest.mark.django_db
def test_ai_classifications_export(idea, comment_factory,
ai_classification_factory,
moderator_comment_statement_factory):

def test_ai_classifications_export(
idea,
comment_factory,
ai_classification_factory,
moderator_comment_feedback_factory,
):
comment_1 = comment_factory(content_object=idea)
comment_2 = comment_factory(content_object=idea)
moderator_statement = moderator_comment_statement_factory(
comment=comment_1)
moderator_feedback = moderator_comment_feedback_factory(comment=comment_1)
ai_classification_1 = ai_classification_factory(comment=comment_1)
ai_classification_2 = ai_classification_factory(
comment=comment_2,
classification='ENGAGING')
comment=comment_2, classification="ENGAGING"
)
ai_classification_3 = ai_classification_factory(comment=comment_1)

ai_classification_export = AIClassificationExport()

header = ai_classification_export.get_header()
assert header == ['ID', 'created', 'classification', 'comment text',
'is pending', 'comment_id', 'comment_comment',
'comment_is_blocked', 'comment_is_moderator_marked',
'comment_created', 'comment_modified',
'comment_moderator_statement']
assert header == [
"ID",
"Created",
"classification",
"comment text",
"is pending",
"comment_id",
"comment_comment",
"comment_is_blocked",
"comment_is_moderator_marked",
"comment_created",
"comment_modified",
"comment_moderator_feedback",
]

queryset = ai_classification_export.get_queryset()
assert queryset.count() == 3
Expand All @@ -35,52 +45,79 @@ def test_ai_classifications_export(idea, comment_factory,
assert ai_classification_3 in queryset

assert ai_classification_export.get_field_data(
ai_classification_1, 'comment_id') == str(comment_1.id)
assert ai_classification_export.get_field_data(
ai_classification_2, 'classification') == 'ENGAGING'
ai_classification_1, "comment_id"
) == str(comment_1.id)
assert (
ai_classification_export.get_field_data(ai_classification_2, "classification")
== "ENGAGING"
)
assert ai_classification_export.get_field_data(
ai_classification_1, 'comment_moderator_statement') == \
str(moderator_statement)
assert ai_classification_export.get_field_data(
ai_classification_2, 'comment_moderator_statement') == ''
ai_classification_1, "comment_moderator_feedback"
) == str(moderator_feedback)
assert (
ai_classification_export.get_field_data(
ai_classification_2, "comment_moderator_feedback"
)
== ""
)


@pytest.mark.django_db
def test_user_classifications_export(idea, comment_factory,
user_classification_factory,
moderator_comment_statement_factory):

def test_user_classifications_export(
idea,
comment_factory,
user_classification_factory,
moderator_comment_feedback_factory,
):
comment_1 = comment_factory(content_object=idea)
comment_2 = comment_factory(content_object=idea)
moderator_statement = moderator_comment_statement_factory(
comment=comment_1)
moderator_feedback = moderator_comment_feedback_factory(comment=comment_1)
user_classification_1 = user_classification_factory(comment=comment_1)
user_classification_2 = user_classification_factory(
comment=comment_2,
user_message='this needs to be reported')
comment=comment_2, user_message="this needs to be reported"
)

user_classification_export = UserClassificationExport()

header = user_classification_export.get_header()
assert header == ['ID', 'created', 'classification', 'comment text',
'is pending', 'comment_id', 'comment_comment',
'comment_is_blocked', 'comment_is_moderator_marked',
'comment_created', 'comment_modified',
'comment_moderator_statement', 'user message']
assert header == [
"ID",
"Created",
"classification",
"comment text",
"is pending",
"comment_id",
"comment_comment",
"comment_is_blocked",
"comment_is_moderator_marked",
"comment_created",
"comment_modified",
"comment_moderator_feedback",
"user message",
]

queryset = user_classification_export.get_queryset()
assert queryset.count() == 2
assert user_classification_1 == queryset.first()
assert user_classification_2 == queryset.last()

assert user_classification_export.get_field_data(
user_classification_1, 'comment_id') == str(comment_1.id)
assert user_classification_export.get_field_data(
user_classification_1, 'user_message') == 'This is bad.'
assert user_classification_export.get_field_data(
user_classification_2, 'user_message') == 'this needs to be reported'
assert user_classification_export.get_field_data(
user_classification_1, 'comment_moderator_statement') == \
str(moderator_statement)
user_classification_1, "comment_id"
) == str(comment_1.id)
assert (
user_classification_export.get_field_data(user_classification_1, "user_message")
== "This is bad."
)
assert (
user_classification_export.get_field_data(user_classification_2, "user_message")
== "this needs to be reported"
)
assert user_classification_export.get_field_data(
user_classification_2, 'comment_moderator_statement') == ''
user_classification_1, "comment_moderator_feedback"
) == str(moderator_feedback)
assert (
user_classification_export.get_field_data(
user_classification_2, "comment_moderator_feedback"
)
== ""
)

0 comments on commit 25b4c17

Please sign in to comment.