-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Group/org updates and frontend changes to load in new data
- Loading branch information
1 parent
74af533
commit 0da7a8d
Showing
36 changed files
with
312 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
27 changes: 27 additions & 0 deletions
27
backend/communities/organizations/tests/test_org_events.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
""" | ||
Test cases for the OrganizationEvents entity. | ||
""" | ||
|
||
import pytest | ||
|
||
from communities.organizations.factories import OrganizationFactory | ||
from communities.organizations.models import Organization | ||
from events.factories import EventFactory | ||
|
||
pytestmark = pytest.mark.django_db | ||
|
||
|
||
def test_multiple_events_per_org() -> None: | ||
"""Test multiple events for a single organization.""" | ||
org = OrganizationFactory.create() | ||
events = EventFactory.create_batch(3) | ||
|
||
org.events.set(events) | ||
|
||
org = Organization.objects.get(id=org.id) | ||
org_events = org.events.all() | ||
|
||
assert len(events) == len(org_events) | ||
|
||
for event in events: | ||
assert event in org_events |
62 changes: 62 additions & 0 deletions
62
backend/communities/organizations/tests/test_org_member.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
""" | ||
Test cases for the OrganizationMember model. | ||
""" | ||
|
||
import pytest | ||
|
||
from authentication.factories import UserFactory | ||
from communities.organizations.factories import ( | ||
OrganizationFactory, | ||
OrganizationMemberFactory, | ||
) | ||
|
||
pytestmark = pytest.mark.django_db | ||
|
||
|
||
def test_org_member_str() -> None: | ||
"""Test string representation of OrganizationMember model.""" | ||
org_member = OrganizationMemberFactory.build() | ||
assert str(org_member) == f"{org_member.id}" | ||
|
||
|
||
def test_org_member_roles() -> None: | ||
"""Test the different roles an organization member can have.""" | ||
user = UserFactory() | ||
org = OrganizationFactory() | ||
|
||
print(org.__dict__) | ||
|
||
# 1. Test owner role. | ||
owner = OrganizationMemberFactory( | ||
org=org, user=user, is_owner=True, is_admin=False, is_comms=False | ||
) | ||
assert owner.is_owner is True | ||
assert owner.is_admin is False | ||
assert owner.is_comms is False | ||
|
||
# 2. Test admin role. | ||
admin = OrganizationMemberFactory( | ||
org=org, user=user, is_owner=False, is_admin=True, is_comms=False | ||
) | ||
assert admin.is_owner is False | ||
assert admin.is_admin is True | ||
assert admin.is_comms is False | ||
|
||
# 3. Test comms role. | ||
comms = OrganizationMemberFactory( | ||
org=org, user=user, is_owner=False, is_admin=False, is_comms=True | ||
) | ||
assert comms.is_owner is False | ||
assert comms.is_admin is False | ||
assert comms.is_comms is True | ||
|
||
|
||
def test_multiple_members_per_org() -> None: | ||
"""Test multiple members in a single organization.""" | ||
org = OrganizationFactory() | ||
members = [OrganizationMemberFactory(org=org) for _ in range(3)] | ||
|
||
assert len(members) == 3 | ||
|
||
for member in members: | ||
assert member.org == org |
35 changes: 35 additions & 0 deletions
35
backend/communities/organizations/tests/test_org_resource.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
""" | ||
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
""" | ||
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
""" | ||
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.