# 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)


from functools import partial
from django.contrib.auth.models import User
from django.test import TestCase
from django.test.utils import override_settings
from organizations.models import Organization
from organizations.utils import create_organization
from organizations.utils import model_field_attr
from test_abstract.models import CustomOrganization
from test_accounts.models import Account




@override_settings(USE_TZ=True)
class CreateOrgTests(TestCase):

    fixtures = ["users.json", "orgs.json"]

    def setUp(self):
        self.user = User.objects.get(username="dave")

    def test_create_organization(self):
        acme = create_organization(
            self.user, "Acme", org_defaults={"slug": "acme-slug"}
        )
        self.assertTrue(isinstance(acme, Organization))
        self.assertEqual(self.user, acme.owner.organization_user.user)
        self.assertTrue(acme.owner.organization_user.is_admin)

    def test_create_custom_org(self):

# 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: tests/test_utils.py
from functools import partial
from django.contrib.auth.models import User
from django.test import TestCase
from django.test.utils import override_settings
from organizations.models import Organization
from organizations.utils import create_organization
from organizations.utils import model_field_attr
from test_abstract.models import CustomOrganization
from test_accounts.models import Account





@override_settings(USE_TZ=True)
class CreateOrgTests(TestCase):

    fixtures = ["users.json", "orgs.json"]

    def setUp(self):
        self.user = User.objects.get(username="dave")

    def test_create_organization(self):
        acme = create_organization(
            self.user, "Acme", org_defaults={"slug": "acme-slug"}
        )
        self.assertTrue(isinstance(acme, Organization))
        self.assertEqual(self.user, acme.owner.organization_user.user)
        self.assertTrue(acme.owner.organization_user.is_admin)

    def test_create_custom_org(self):

        custom = create_organization(self.user, "Custom", model=Account)