# Path: test_abstract/models.py
# class CustomOrganization(AbstractOrganization):
#     street_address = models.CharField(max_length=100, default="")
#     city = models.CharField(max_length=100, default="")
# 
# Path: test_accounts/models.py
# class Account(OrganizationBase):
#     monthly_subscription = models.IntegerField(default=1000)
# 
# Path: test_accounts/models.py
# class AccountInvitation(OrganizationInvitationBase):
# 
#     def get_absolute_url(self):
#         """Returns the invitation URL"""
#         return reverse(
#             "test_accounts:account_invitations:invitations_register",
#             kwargs={"guid": str(self.guid)},
#         )


from functools import partial
from django.contrib.auth.models import User
from django.db import IntegrityError
from django.test import TestCase
from django.test.utils import override_settings
from organizations.models import Organization
from organizations.models import OrganizationInvitation
from organizations.models import OrganizationOwner
from organizations.models import OrganizationUser
from organizations.utils import create_organization
from test_abstract.models import CustomOrganization
from test_accounts.models import Account
from test_accounts.models import AccountInvitation
from test_custom.models import Team
        from organizations.exceptions import OwnershipRequired
        from organizations.exceptions import OrganizationMismatch
        self.dave = User.objects.get(username="dave")
        self.krist = User.objects.get(username="krist")
        self.duder = User.objects.get(username="duder")
        self.red_account = Account.objects.create(
            name="Red Account", monthly_subscription=1200
        )

    def test_invitation_model(self):
        assert Account.invitation_model == AccountInvitation

    def test_org_string(self):
        self.assertEqual(self.red_account.__str__(), "Red Account")

    def test_relation_name(self):
        """Ensure user-related name is accessible from common attribute"""
        self.assertEqual(self.red_account.user_relation_name, "test_accounts_account")

    def test_change_user(self):
        """Ensure custom organizations validate in owner change"""
        create_team = partial(create_organization, model=Team)
        hometeam = create_team(self.dave, "Hometeam")
        duder_org_user = hometeam.add_user(self.duder)
        hometeam.owner.organization_user = duder_org_user
        hometeam.owner.save()

    def test_abstract_change_user(self):
        """
        Ensure custom organizations inheriting abstract model
        validate in owner change
        """

# Path: test_abstract/models.py
# class CustomOrganization(AbstractOrganization):
#     street_address = models.CharField(max_length=100, default="")
#     city = models.CharField(max_length=100, default="")
# 
# Path: test_accounts/models.py
# class Account(OrganizationBase):
#     monthly_subscription = models.IntegerField(default=1000)
# 
# Path: test_accounts/models.py
# class AccountInvitation(OrganizationInvitationBase):
# 
#     def get_absolute_url(self):
#         """Returns the invitation URL"""
#         return reverse(
#             "test_accounts:account_invitations:invitations_register",
#             kwargs={"guid": str(self.guid)},
#         )


# Path: tests/test_models.py
from functools import partial
from django.contrib.auth.models import User
from django.db import IntegrityError
from django.test import TestCase
from django.test.utils import override_settings
from organizations.models import Organization
from organizations.models import OrganizationInvitation
from organizations.models import OrganizationOwner
from organizations.models import OrganizationUser
from organizations.utils import create_organization
from test_abstract.models import CustomOrganization
from test_accounts.models import Account
from test_accounts.models import AccountInvitation
from test_custom.models import Team
        from organizations.exceptions import OwnershipRequired
        from organizations.exceptions import OrganizationMismatch

        self.dave = User.objects.get(username="dave")
        self.krist = User.objects.get(username="krist")
        self.duder = User.objects.get(username="duder")
        self.red_account = Account.objects.create(
            name="Red Account", monthly_subscription=1200
        )

    def test_invitation_model(self):
        assert Account.invitation_model == AccountInvitation

    def test_org_string(self):
        self.assertEqual(self.red_account.__str__(), "Red Account")

    def test_relation_name(self):
        """Ensure user-related name is accessible from common attribute"""
        self.assertEqual(self.red_account.user_relation_name, "test_accounts_account")

    def test_change_user(self):
        """Ensure custom organizations validate in owner change"""
        create_team = partial(create_organization, model=Team)
        hometeam = create_team(self.dave, "Hometeam")
        duder_org_user = hometeam.add_user(self.duder)
        hometeam.owner.organization_user = duder_org_user
        hometeam.owner.save()

    def test_abstract_change_user(self):
        """
        Ensure custom organizations inheriting abstract model
        validate in owner change
        """

        create_org = partial(create_organization, model=CustomOrganization)