Skip to content

Commit

Permalink
fix(topic): enhance tests to prevent non-fr content error
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Aug 13, 2024
1 parent d932b67 commit 361fffc
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions lacommunaute/forum_conversation/tests/tests_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_create_topic_as_anonymous(self, db, client, public_forum):

response = client.post(
get_create_topic_url(public_forum),
data={"subject": "Test", "content": faker.sentences(2), "username": username},
data={"subject": "Test", "content": faker.paragraph(nb_sentences=5), "username": username},
)
assert response.status_code == 302

Expand All @@ -120,7 +120,7 @@ def test_update_anonymous_topic_as_self(self, db, client, public_forum):
session = client.session
session["anonymous_topic"] = topic.first_post.anonymous_key

data = {"subject": faker.word(), "content": faker.sentences(2), "username": username}
data = {"subject": faker.word(), "content": faker.paragraph(nb_sentences=5), "username": username}
response = client.post(get_update_topic_url(topic), data=data)
assert response.status_code == 302

Expand All @@ -139,7 +139,7 @@ def test_update_anonymous_topic_as_superuser(self, db, client, public_forum):

data = {
"subject": faker.word(),
"content": faker.sentences(2),
"content": faker.paragraph(nb_sentences=5),
**superuser_hidden_fields,
}
response = client.post(get_update_topic_url(topic), data=data)
Expand All @@ -157,7 +157,8 @@ def test_create_topic_as_authenticated(self, db, client, public_forum):
client.force_login(user)

response = client.post(
get_create_topic_url(public_forum), data={"subject": "Test", "content": faker.sentences(2)}
get_create_topic_url(public_forum),
data={"subject": faker.word(), "content": faker.paragraph(nb_sentences=5)},
)
assert response.status_code == 302

Expand All @@ -173,7 +174,7 @@ def test_update_authenticated_topic_as_self(self, db, client, public_forum):
user = topic.poster
client.force_login(user)

data = {"subject": faker.word(), "content": faker.sentences(2)}
data = {"subject": faker.word(), "content": faker.paragraph(nb_sentences=5)}
response = client.post(get_update_topic_url(topic), data=data)
assert response.status_code == 302

Expand All @@ -192,7 +193,7 @@ def test_update_authenticated_topic_as_superuser(self, db, client, public_forum)

data = {
"subject": faker.word(),
"content": faker.sentences(2),
"content": faker.paragraph(nb_sentences=5),
**superuser_hidden_fields,
}
response = client.post(get_update_topic_url(topic), data=data)
Expand Down Expand Up @@ -231,7 +232,9 @@ def test_reply_as_anonymous(self, db, client, public_forum):
topic = TopicFactory(forum=public_forum, with_post=True)
username = faker.email()

response = client.post(get_reply_topic_url(topic), data={"content": faker.sentences(2), "username": username})
response = client.post(
get_reply_topic_url(topic), data={"content": faker.paragraph(nb_sentences=5), "username": username}
)
assert response.status_code == 200 # htmx view

topic.refresh_from_db()
Expand All @@ -247,7 +250,7 @@ def test_update_anonymous_reply_as_self(self, db, client, public_forum):
session = client.session
session["anonymous_post"] = post.anonymous_key

data = {"content": faker.sentences(2), "username": username}
data = {"content": faker.paragraph(nb_sentences=5), "username": username}
response = client.post(get_post_update_url(post), data=data)
assert response.status_code == 302

Expand All @@ -263,7 +266,7 @@ def test_update_anonymous_reply_as_superuser(self, db, client, public_forum):
superuser = UserFactory(is_superuser=True)
client.force_login(superuser)

data = {"content": faker.sentences(2), **superuser_hidden_fields}
data = {"content": faker.paragraph(nb_sentences=5), **superuser_hidden_fields}
response = client.post(get_post_update_url(post), data=data)
assert response.status_code == 302

Expand All @@ -278,7 +281,7 @@ def test_reply_as_authenticated(self, db, client, public_forum):
user = UserFactory()
client.force_login(user)

response = client.post(get_reply_topic_url(topic), data={"content": faker.sentences(2)})
response = client.post(get_reply_topic_url(topic), data={"content": faker.paragraph(nb_sentences=5)})
assert response.status_code == 200

topic.refresh_from_db()
Expand All @@ -295,7 +298,7 @@ def test_update_authenticated_reply_as_self(self, db, client, public_forum):
user = post.poster
client.force_login(user)

data = {"content": faker.sentences(2)}
data = {"content": faker.paragraph(nb_sentences=5)}
response = client.post(get_post_update_url(post), data=data)
assert response.status_code == 302

Expand All @@ -311,7 +314,7 @@ def test_update_authenticated_reply_as_superuser(self, db, client, public_forum)
superuser = UserFactory(is_superuser=True)
client.force_login(superuser)

data = {"content": faker.sentences(2), **superuser_hidden_fields}
data = {"content": faker.paragraph(nb_sentences=5), **superuser_hidden_fields}
response = client.post(get_post_update_url(post), data=data)
assert response.status_code == 302

Expand Down

0 comments on commit 361fffc

Please sign in to comment.