# 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: test_vendors/models.py
# class Vendor(OrganizationBase):
#     street_address = models.CharField(max_length=100, default="")
#     city = models.CharField(max_length=100, default="")


from django.contrib.auth.models import User
from django.core import mail
from organizations.backends.defaults import InvitationBackend
from organizations.backends.modeled import ModelInvitation
from organizations.base import OrganizationInvitationBase
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_vendors.models import Vendor
import pytest
    ):
        client.force_login(account_user)
        response = client.get(email_invitation.get_absolute_url())
        assert response.status_code == 403

    def test_existing_user_is_not_linked_as_invitee_at_invitation_time(
        self, email_invitation, invitee_user, account_user, account_account, client
    ):
        assert email_invitation.invitee is None
        assert email_invitation.invitee_identifier == invitee_user.email

    def test_existing_user_can_view_the_invitation(
        self, email_invitation, invitee_user, client
    ):
        client.force_login(invitee_user)
        response = client.get(email_invitation.get_absolute_url())
        assert response.status_code == 200

    def test_existing_user_activating_invitation(
        self, email_invitation, invitee_user, client
    ):
        # Need an org with an invite to a user who is logged in
        client.force_login(invitee_user)
        client.post(email_invitation.get_absolute_url())
        email_invitation.refresh_from_db()
        assert email_invitation.invitee == invitee_user

    def test_accessing_invitation_once_it_has_been_used(
        self, invitee_user, account_user, account_account, client
    ):

# 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: test_vendors/models.py
# class Vendor(OrganizationBase):
#     street_address = models.CharField(max_length=100, default="")
#     city = models.CharField(max_length=100, default="")


# Path: tests/backends/test_model_based_backend.py
from django.contrib.auth.models import User
from django.core import mail
from organizations.backends.defaults import InvitationBackend
from organizations.backends.modeled import ModelInvitation
from organizations.base import OrganizationInvitationBase
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_vendors.models import Vendor
import pytest

    ):
        client.force_login(account_user)
        response = client.get(email_invitation.get_absolute_url())
        assert response.status_code == 403

    def test_existing_user_is_not_linked_as_invitee_at_invitation_time(
        self, email_invitation, invitee_user, account_user, account_account, client
    ):
        assert email_invitation.invitee is None
        assert email_invitation.invitee_identifier == invitee_user.email

    def test_existing_user_can_view_the_invitation(
        self, email_invitation, invitee_user, client
    ):
        client.force_login(invitee_user)
        response = client.get(email_invitation.get_absolute_url())
        assert response.status_code == 200

    def test_existing_user_activating_invitation(
        self, email_invitation, invitee_user, client
    ):
        # Need an org with an invite to a user who is logged in
        client.force_login(invitee_user)
        client.post(email_invitation.get_absolute_url())
        email_invitation.refresh_from_db()
        assert email_invitation.invitee == invitee_user

    def test_accessing_invitation_once_it_has_been_used(
        self, invitee_user, account_user, account_account, client
    ):

        invitation = AccountInvitation.objects.create(