import pytest

from servala.core.models import (
    Organization,
    OrganizationMembership,
    OrganizationOrigin,
    User,
)


@pytest.fixture
def origin():
    return OrganizationOrigin.objects.create(name="TESTORIGIN")


@pytest.fixture
def organization(origin):
    return Organization.objects.create(name="Test Org", origin=origin)


@pytest.fixture
def other_organization(origin):
    return Organization.objects.create(name="Test Org Alternate", origin=origin)


@pytest.fixture
def org_owner(organization):
    user = User.objects.create(email="user@example.org", password="example")
    OrganizationMembership.objects.create(
        organization=organization, user=user, role="owner"
    )
    return user
