forked from activist-org/activist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_org_resource.py
40 lines (28 loc) · 955 Bytes
/
test_org_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 OrganizationResource model.
"""
import pytest
from communities.organizations.factories import OrganizationFactory
from content.factories import ResourceFactory
from content.models import Resource
pytestmark = pytest.mark.django_db
def test_org_resource_creation() -> None:
"""
Test creating a OrganizationResource instance.
"""
org = OrganizationFactory()
resource = ResourceFactory()
org.resources.set([resource])
assert isinstance(org.resources.first(), Resource)
assert org.resources.first() == resource
def test_multiple_resources_per_org() -> None:
"""
Test multiple resources for a single organization.
"""
org = OrganizationFactory()
resources = ResourceFactory.create_batch(3)
org.resources.set(resources)
assert len(resources) == 3
for resource in resources:
assert resource in org.resources.all()