47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
from factory import DjangoModelFactory, Sequence, SubFactory
|
|
from factory.fuzzy import FuzzyText, FuzzyChoice, FuzzyInteger
|
|
|
|
from ..models import Species, Sex, TrapSpecies, CollectionSpecies
|
|
from ccdb.collections_ccdb.tests.factories import (CollectionFactory,
|
|
CollectionTrapFactory)
|
|
|
|
|
|
class SpeciesFactory(DjangoModelFactory):
|
|
class Meta:
|
|
model = Species
|
|
|
|
common_name = Sequence(lambda n: 'species{}'.format(n))
|
|
genus = FuzzyText(length=50)
|
|
species = FuzzyText(length=50)
|
|
parasite = FuzzyChoice(choices=[True, False])
|
|
sort_order = Sequence(lambda n: n)
|
|
|
|
|
|
class SexFactory(DjangoModelFactory):
|
|
class Meta:
|
|
model = Sex
|
|
|
|
name = Sequence(lambda n: 'sex{}'.format(n))
|
|
sort_order = Sequence(lambda n: n)
|
|
|
|
|
|
class TrapSpeciesFactory(DjangoModelFactory):
|
|
class Meta:
|
|
model = TrapSpecies
|
|
|
|
collection_trap = SubFactory(CollectionTrapFactory)
|
|
species = SubFactory(SpeciesFactory)
|
|
sex = SubFactory(SexFactory)
|
|
count = FuzzyInteger(0)
|
|
count_estimated = FuzzyChoice(choices=[True, False])
|
|
|
|
|
|
class CollectionSpeciesFactory(DjangoModelFactory):
|
|
class Meta:
|
|
model = CollectionSpecies
|
|
|
|
collection = SubFactory(CollectionFactory)
|
|
species = SubFactory(SpeciesFactory)
|
|
sex = SubFactory(SexFactory)
|
|
count = FuzzyInteger(0)
|
|
count_estimated = FuzzyChoice(choices=[True, False])
|