forked from activist-org/activist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_group_text.py
61 lines (49 loc) · 1.59 KB
/
test_group_text.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Test cases for the GroupText model.
"""
import pytest
from communities.groups.factories import GroupFactory, GroupTextFactory
pytestmark = pytest.mark.django_db
def test_group_text_str() -> None:
"""
Test string representation of GroupText model.
"""
group_text = GroupTextFactory.build()
assert hasattr(group_text, "description")
def test_group_text_languages() -> None:
"""
Test group text with different ISO languages.
"""
group = GroupFactory()
# 1. Test primary language text.
primary_text = GroupTextFactory(
group=group,
iso="eng",
primary=True,
description="Primary description",
get_involved="Get involved text",
donate_prompt="Donation prompt",
)
assert primary_text.primary is True
assert primary_text.iso == "eng"
assert primary_text.description == "Primary description"
# 2. Test secondary language text.
secondary_text = GroupTextFactory(
group=group,
iso="spa",
primary=False,
description="Description",
get_involved="How to participate",
donate_prompt="Donation prompt",
)
assert secondary_text.primary is False
assert secondary_text.iso == "spa"
assert secondary_text.description == "Description"
def test_group_text_str_representation() -> None:
"""
Test string representation of GroupText model.
"""
group = GroupFactory()
group_text = GroupTextFactory(group=group, iso="eng")
assert str(group_text) == f"{group_text.group} - {group_text.iso}"