forked from activist-org/activist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_org_topic.py
39 lines (28 loc) · 882 Bytes
/
test_org_topic.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
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Test cases for OrganizationTopic model.
"""
import pytest
from communities.organizations.factories import OrganizationFactory
from content.factories import TopicFactory
from content.models import Topic
pytestmark = pytest.mark.django_db
def test_org_topic_creation() -> None:
"""
Test creating a OrganizationTopic instance.
"""
org = OrganizationFactory()
topic = TopicFactory()
org.topics.set([topic])
assert isinstance(org.topics.first(), Topic)
assert org.topics.first() == topic
def test_multiple_topics_per_org() -> None:
"""
Test multiple topics for a single organization.
"""
org = OrganizationFactory()
topics = TopicFactory.create_batch(3)
org.topics.set(topics)
assert len(topics) == 3
for topic in topics:
assert topic in org.topics.all()