Skip to content

Commit

Permalink
add test factories
Browse files Browse the repository at this point in the history
  • Loading branch information
henrinie-nc authored and NC-jsAhonen committed Nov 21, 2024
1 parent 23a2f2b commit 3a77bee
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
38 changes: 37 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from batchrun.models import Command, Job, JobRun, JobRunLog
from forms.models import Answer, Choice, Entry, Field, Form, Section
from forms.models.form import EntrySection
from forms.models.form import Attachment, EntrySection
from forms.tests.conftest import fake
from forms.utils import EmailMessageInput
from leasing.enums import (
Expand Down Expand Up @@ -40,7 +40,10 @@
from leasing.models.receivable_type import ReceivableType
from plotsearch.models import (
AreaSearch,
AreaSearchAttachment,
AreaSearchIntendedUse,
Favourite,
InformationCheck,
PlotSearch,
PlotSearchStage,
PlotSearchSubtype,
Expand Down Expand Up @@ -175,6 +178,18 @@ class Meta:
model = AreaSearch


@register
class AreaSearchAttachmentFactory(factory.django.DjangoModelFactory):
class Meta:
model = AreaSearchAttachment


@register
class FavouriteFactory(factory.django.DjangoModelFactory):
class Meta:
model = Favourite


@register
class LeaseTypeFactory(factory.django.DjangoModelFactory):
identifier = factory.Sequence(lambda n: "A%10d" % n)
Expand Down Expand Up @@ -504,12 +519,16 @@ class Meta:

@register
class SectionFactory(factory.django.DjangoModelFactory):
form = factory.SubFactory(FormFactory)

class Meta:
model = Section


@register
class FieldFactory(factory.django.DjangoModelFactory):
section = factory.SubFactory(SectionFactory)

class Meta:
model = Field

Expand Down Expand Up @@ -561,6 +580,15 @@ class Meta:
model = Answer


@register
class AttachmentFactory(factory.django.DjangoModelFactory):

field = factory.SubFactory(FieldFactory)

class Meta:
model = Attachment


@pytest.fixture
def basic_template_form(
form_factory,
Expand Down Expand Up @@ -1204,6 +1232,14 @@ class Meta:
answer = factory.SubFactory(AnswerFactory)


@register
class InformationCheckFactory(factory.django.DjangoModelFactory):
entry_section = factory.SubFactory(EntrySectionFactory)

class Meta:
model = InformationCheck


@register
class RelatedPlotApplicationFactory(factory.django.DjangoModelFactory):
lease = factory.SubFactory(LeaseFactory)
Expand Down
2 changes: 2 additions & 0 deletions plotsearch/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from .plot_search import (
FAQ,
AreaSearch,
AreaSearchAttachment,
AreaSearchIntendedUse,
Favourite,
FavouriteTarget,
Expand All @@ -22,6 +23,7 @@
"Favourite",
"FavouriteTarget",
"InformationCheck",
"AreaSearchAttachment",
"AreaSearchIntendedUse",
"PlotSearch",
"PlotSearchStage",
Expand Down

0 comments on commit 3a77bee

Please sign in to comment.