|
| 1 | +# SPDX-License-Identifier: AGPL-3.0-or-later |
| 2 | + |
| 3 | +import datetime |
| 4 | + |
| 5 | +import pytest |
| 6 | + |
| 7 | +from communities.factories import StatusTypeFactory |
| 8 | +from communities.organizations.factories import ( |
| 9 | + OrganizationApplicationStatusFactory, |
| 10 | + OrganizationFactory, |
| 11 | + OrganizationImageFactory, |
| 12 | + OrganizationTextFactory, |
| 13 | +) |
| 14 | +from communities.organizations.models import OrganizationApplication |
| 15 | + |
| 16 | +pytestmark = pytest.mark.django_db |
| 17 | + |
| 18 | + |
| 19 | +def test_organization_application_str() -> None: |
| 20 | + """Test string representation of OrganizationApplication model.""" |
| 21 | + |
| 22 | + org = OrganizationFactory.build() |
| 23 | + status = StatusTypeFactory() |
| 24 | + |
| 25 | + # OrganizationApplication instead of OrganizationApplicationFactory (many-to-many field assignment issues). |
| 26 | + org_application = OrganizationApplication( |
| 27 | + org=org, |
| 28 | + status=status, |
| 29 | + creation_date=datetime.datetime.now(tz=datetime.timezone.utc), |
| 30 | + ) |
| 31 | + |
| 32 | + assert str(org_application) == f"{org_application.creation_date}" |
| 33 | + |
| 34 | + assert str(org_application) == f"{org_application.creation_date}" |
| 35 | + |
| 36 | + |
| 37 | +def test_organization_application_status_str() -> None: |
| 38 | + """Test string representation of OrganizationApplicationStatus model.""" |
| 39 | + status = OrganizationApplicationStatusFactory.build(status_name="Approved") |
| 40 | + assert str(status) == "Approved" |
| 41 | + |
| 42 | + |
| 43 | +def test_organization_image_str() -> None: |
| 44 | + """Test string representation of OrganizationImage model.""" |
| 45 | + org_image = OrganizationImageFactory.build() |
| 46 | + assert str(org_image) == f"{org_image.id}" |
| 47 | + |
| 48 | + |
| 49 | +def test_organization_text_str() -> None: |
| 50 | + """Test string representation of OrganizationText model.""" |
| 51 | + org_text = OrganizationTextFactory.build(iso="en") |
| 52 | + org = org_text.org |
| 53 | + assert str(org_text) == f"{org} - en" |
0 commit comments