forked from activist-org/activist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_org_text.py
54 lines (45 loc) · 1.38 KB
/
test_org_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
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Test cases for the OrganizationText model.
"""
import pytest
from communities.organizations.factories import (
OrganizationFactory,
OrganizationTextFactory,
)
pytestmark = pytest.mark.django_db
def test_org_text_str() -> None:
"""
Test string representation of OrganizationText model.
"""
org_text = OrganizationTextFactory.build()
assert hasattr(org_text, "description")
def test_org_text_languages() -> None:
"""
Test organization text with different ISO languages.
"""
org = OrganizationFactory()
# 1. Test primary language text.
primary_text = OrganizationTextFactory(
org=org,
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 = OrganizationTextFactory(
org=org,
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"