forked from activist-org/activist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_group_resource.py
40 lines (28 loc) · 924 Bytes
/
test_group_resource.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
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Test cases for GroupResource model.
"""
import pytest
from communities.groups.factories import GroupFactory
from content.factories import ResourceFactory
from content.models import Resource
pytestmark = pytest.mark.django_db
def test_group_resource_creation() -> None:
"""
Test creating a GroupResource instance.
"""
group = GroupFactory()
resource = ResourceFactory()
group.resources.set([resource])
assert isinstance(group.resources.first(), Resource)
assert group.resources.first() == resource
def test_multiple_resources_per_group() -> None:
"""
Test multiple resources for a single group.
"""
group = GroupFactory()
resources = ResourceFactory.create_batch(3)
group.resources.set(resources)
assert len(resources) == 3
for resource in resources:
assert resource in group.resources.all()