Some checks failed
CodeQL / Analyze (javascript) (push) Failing after 16s
CodeQL / Analyze (python) (push) Failing after 3s
i18n sync check / check:sync (push) Failing after 3s
React Doctor / react-doctor (push) Failing after 16s
Branch Build CE / Build-Push Admin Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Admin Manifest (push) Has been cancelled
Branch Build CE / Build-Push Web Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Web Manifest (push) Has been cancelled
Branch Build CE / Build-Push Space Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Proxy Manifest (push) Has been cancelled
Branch Build CE / Merge Space Manifest (push) Has been cancelled
Branch Build CE / Prepare AIO Assets (push) Has been cancelled
Branch Build CE / Build Setup (push) Has been cancelled
Branch Build CE / Build-Push Live Collaboration Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Live Collaboration Manifest (push) Has been cancelled
Branch Build CE / Build-Push API Server Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge API Server Manifest (push) Has been cancelled
Branch Build CE / Build-Push Proxy Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Build-Push AIO Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge AIO Manifest (push) Has been cancelled
Branch Build CE / Upload Build Assets (push) Has been cancelled
Branch Build CE / Build Release (push) Has been cancelled
86 lines
2.7 KiB
Python
86 lines
2.7 KiB
Python
# Copyright (c) 2023-present Plane Software, Inc. and contributors
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
# See the LICENSE file for details.
|
|
|
|
import factory
|
|
from uuid import uuid4
|
|
from django.utils import timezone
|
|
|
|
from plane.db.models import User, Workspace, WorkspaceMember, Project, ProjectMember
|
|
|
|
|
|
class UserFactory(factory.django.DjangoModelFactory):
|
|
"""Factory for creating User instances"""
|
|
|
|
class Meta:
|
|
model = User
|
|
django_get_or_create = ("email",)
|
|
|
|
id = factory.LazyFunction(uuid4)
|
|
email = factory.Sequence(lambda n: f"user{n}@plane.so")
|
|
password = factory.PostGenerationMethodCall("set_password", "password")
|
|
first_name = factory.Sequence(lambda n: f"First{n}")
|
|
last_name = factory.Sequence(lambda n: f"Last{n}")
|
|
is_active = True
|
|
is_superuser = False
|
|
is_staff = False
|
|
|
|
|
|
class WorkspaceFactory(factory.django.DjangoModelFactory):
|
|
"""Factory for creating Workspace instances"""
|
|
|
|
class Meta:
|
|
model = Workspace
|
|
django_get_or_create = ("slug",)
|
|
|
|
id = factory.LazyFunction(uuid4)
|
|
name = factory.Sequence(lambda n: f"Workspace {n}")
|
|
slug = factory.Sequence(lambda n: f"workspace-{n}")
|
|
owner = factory.SubFactory(UserFactory)
|
|
created_at = factory.LazyFunction(timezone.now)
|
|
updated_at = factory.LazyFunction(timezone.now)
|
|
|
|
|
|
class WorkspaceMemberFactory(factory.django.DjangoModelFactory):
|
|
"""Factory for creating WorkspaceMember instances"""
|
|
|
|
class Meta:
|
|
model = WorkspaceMember
|
|
|
|
id = factory.LazyFunction(uuid4)
|
|
workspace = factory.SubFactory(WorkspaceFactory)
|
|
member = factory.SubFactory(UserFactory)
|
|
role = 20 # Admin role by default
|
|
created_at = factory.LazyFunction(timezone.now)
|
|
updated_at = factory.LazyFunction(timezone.now)
|
|
|
|
|
|
class ProjectFactory(factory.django.DjangoModelFactory):
|
|
"""Factory for creating Project instances"""
|
|
|
|
class Meta:
|
|
model = Project
|
|
django_get_or_create = ("name", "workspace")
|
|
|
|
id = factory.LazyFunction(uuid4)
|
|
name = factory.Sequence(lambda n: f"Project {n}")
|
|
workspace = factory.SubFactory(WorkspaceFactory)
|
|
created_by = factory.SelfAttribute("workspace.owner")
|
|
updated_by = factory.SelfAttribute("workspace.owner")
|
|
created_at = factory.LazyFunction(timezone.now)
|
|
updated_at = factory.LazyFunction(timezone.now)
|
|
|
|
|
|
class ProjectMemberFactory(factory.django.DjangoModelFactory):
|
|
"""Factory for creating ProjectMember instances"""
|
|
|
|
class Meta:
|
|
model = ProjectMember
|
|
|
|
id = factory.LazyFunction(uuid4)
|
|
project = factory.SubFactory(ProjectFactory)
|
|
member = factory.SubFactory(UserFactory)
|
|
role = 20 # Admin role by default
|
|
created_at = factory.LazyFunction(timezone.now)
|
|
updated_at = factory.LazyFunction(timezone.now)
|