MAINT: Refactor, move factories into tests
This commit is contained in:
parent
31714215d0
commit
02a21306fe
16 changed files with 49 additions and 42 deletions
|
@ -4,11 +4,12 @@ from factory import DjangoModelFactory, Sequence, SubFactory, LazyFunction
|
|||
from factory.fuzzy import FuzzyText, FuzzyDate, FuzzyInteger
|
||||
from factory.django import FileField
|
||||
|
||||
from .models import CollectionType, CollectionMethod, Flaw, ADFGPermit, Collection, \
|
||||
DatasheetAttachment, CollectionTrap
|
||||
from ..projects.factories import ProjectFactory
|
||||
from ..locations.factories import StudyLocationFactory, StorageLocationFactory
|
||||
from ..processing.factories import ProcessTypeFactory, ReagentFactory
|
||||
from ..models import (CollectionType, CollectionMethod, Flaw, ADFGPermit,
|
||||
Collection, DatasheetAttachment, CollectionTrap)
|
||||
from ccdb.projects.tests.factories import ProjectFactory
|
||||
from ccdb.locations.tests.factories import (StudyLocationFactory,
|
||||
StorageLocationFactory)
|
||||
from ccdb.processing.tests.factories import ProcessTypeFactory, ReagentFactory
|
||||
|
||||
|
||||
class CollectionTypeFactory(DjangoModelFactory):
|
|
@ -1,11 +1,11 @@
|
|||
from django.test import TestCase
|
||||
from django.db import IntegrityError, transaction
|
||||
|
||||
from ..models import CollectionType, CollectionMethod, Flaw, ADFGPermit, \
|
||||
Collection, DatasheetAttachment, CollectionTrap
|
||||
from ..factories import CollectionTypeFactory, CollectionMethodFactory, \
|
||||
FlawFactory, ADFGPermitFactory, CollectionFactory, DatasheetAttachmentFactory, \
|
||||
CollectionTrapFactory
|
||||
from ..models import (CollectionType, CollectionMethod, Flaw, ADFGPermit,
|
||||
Collection, DatasheetAttachment, CollectionTrap)
|
||||
from .factories import (CollectionTypeFactory, CollectionMethodFactory,
|
||||
FlawFactory, ADFGPermitFactory, CollectionFactory,
|
||||
DatasheetAttachmentFactory, CollectionTrapFactory)
|
||||
|
||||
|
||||
class CollectionTypeTestCase(TestCase):
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
from datetime import date, time
|
||||
|
||||
from factory import DjangoModelFactory, Sequence, SubFactory, \
|
||||
LazyFunction, post_generation
|
||||
from factory import (DjangoModelFactory, Sequence, SubFactory, LazyFunction,
|
||||
post_generation)
|
||||
from factory.fuzzy import FuzzyText, FuzzyDate, FuzzyInteger, FuzzyFloat
|
||||
from factory.django import FileField
|
||||
|
||||
from .models import Flaw, Experiment, ProtocolAttachment, TreatmentType, \
|
||||
Treatment, TreatmentReplicate, AliveDeadCount
|
||||
from ..misc.factories import ContainerFactory
|
||||
from ..locations.factories import StudyLocationFactory
|
||||
from ..species.factories import SpeciesFactory
|
||||
from ..models import (Flaw, Experiment, ProtocolAttachment, TreatmentType,
|
||||
Treatment, TreatmentReplicate, AliveDeadCount)
|
||||
from ccdb.misc.tests.factories import ContainerFactory
|
||||
from ccdb.locations.tests.factories import StudyLocationFactory
|
||||
from ccdb.species.tests.factories import SpeciesFactory
|
||||
|
||||
|
||||
class FlawFactory(DjangoModelFactory):
|
|
@ -1,11 +1,12 @@
|
|||
from django.test import TestCase
|
||||
from django.db import IntegrityError, transaction
|
||||
|
||||
from ..models import Flaw, Experiment, ProtocolAttachment, TreatmentType, \
|
||||
Treatment, TreatmentReplicate, AliveDeadCount
|
||||
from ..factories import FlawFactory, ExperimentFactory, ProtocolAttachmentFactory, \
|
||||
TreatmentTypeFactory, TreatmentFactory, TreatmentReplicateFactory, \
|
||||
AliveDeadCountFactory
|
||||
from ..models import (Flaw, Experiment, ProtocolAttachment, TreatmentType,
|
||||
Treatment, TreatmentReplicate, AliveDeadCount)
|
||||
from .factories import (FlawFactory, ExperimentFactory,
|
||||
ProtocolAttachmentFactory, TreatmentTypeFactory,
|
||||
TreatmentFactory, TreatmentReplicateFactory,
|
||||
AliveDeadCountFactory)
|
||||
|
||||
|
||||
class FlawTestCase(TestCase):
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
from factory import DjangoModelFactory, Sequence, SubFactory
|
||||
from factory.fuzzy import FuzzyText, FuzzyChoice, FuzzyInteger
|
||||
|
||||
from .models import Region, Site, MunicipalLocation, StudyLocation, StorageLocation
|
||||
from ..models import (Region, Site, MunicipalLocation, StudyLocation,
|
||||
StorageLocation)
|
||||
|
||||
|
||||
class RegionFactory(DjangoModelFactory):
|
|
@ -1,9 +1,10 @@
|
|||
from django.test import TestCase
|
||||
from django.db import IntegrityError, transaction
|
||||
|
||||
from ..models import Region, Site, MunicipalLocation, StudyLocation, StorageLocation
|
||||
from ..factories import RegionFactory, SiteFactory, MunicipalLocationFactory, \
|
||||
StudyLocationFactory, StorageLocationFactory
|
||||
from ..models import (Region, Site, MunicipalLocation, StudyLocation,
|
||||
StorageLocation)
|
||||
from .factories import (RegionFactory, SiteFactory, MunicipalLocationFactory,
|
||||
StudyLocationFactory, StorageLocationFactory)
|
||||
|
||||
|
||||
class RegionTestCase(TestCase):
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import factory
|
||||
|
||||
from .models import MeasurementUnit, MeasurementType, Material, Color, Container
|
||||
from ..models import (MeasurementUnit, MeasurementType, Material, Color,
|
||||
Container)
|
||||
|
||||
|
||||
class MeasurementUnitFactory(factory.DjangoModelFactory):
|
|
@ -1,9 +1,10 @@
|
|||
from django.test import TestCase
|
||||
from django.db import IntegrityError, transaction
|
||||
|
||||
from ..models import MeasurementUnit, MeasurementType, Material, Color, Container
|
||||
from ..factories import MeasurementUnitFactory, MeasurementTypeFactory, \
|
||||
MaterialFactory, ColorFactory, ContainerFactory
|
||||
from ..models import (MeasurementUnit, MeasurementType, Material, Color,
|
||||
Container)
|
||||
from .factories import (MeasurementUnitFactory, MeasurementTypeFactory,
|
||||
MaterialFactory, ColorFactory, ContainerFactory)
|
||||
|
||||
|
||||
class MeasurementUnitTestCase(TestCase):
|
||||
|
|
|
@ -3,8 +3,8 @@ from datetime import datetime, date
|
|||
from factory import DjangoModelFactory, Sequence, SubFactory, LazyFunction
|
||||
from factory.fuzzy import FuzzyText, FuzzyDate, FuzzyFloat, FuzzyInteger
|
||||
|
||||
from .models import ProcessType, Reagent, Flaw, Processing
|
||||
from ..misc.factories import ContainerFactory, MeasurementUnitFactory
|
||||
from ..models import ProcessType, Reagent, Flaw, Processing
|
||||
from ccdb.misc.tests.factories import ContainerFactory, MeasurementUnitFactory
|
||||
|
||||
|
||||
class ProcessTypeFactory(DjangoModelFactory):
|
|
@ -2,7 +2,8 @@ from django.test import TestCase
|
|||
from django.db import IntegrityError, transaction
|
||||
|
||||
from ..models import ProcessType, Reagent, Flaw, Processing
|
||||
from ..factories import ProcessTypeFactory, ReagentFactory, FlawFactory, ProcessingFactory
|
||||
from .factories import (ProcessTypeFactory, ReagentFactory, FlawFactory,
|
||||
ProcessingFactory)
|
||||
|
||||
|
||||
class ProcessTypeTestCase(TestCase):
|
||||
|
|
|
@ -2,7 +2,7 @@ from datetime import datetime
|
|||
|
||||
import factory
|
||||
|
||||
from .models import Project, Grant, GrantReport
|
||||
from ..models import Project, Grant, GrantReport
|
||||
|
||||
|
||||
class ProjectFactory(factory.DjangoModelFactory):
|
|
@ -2,7 +2,7 @@ from django.test import TestCase
|
|||
from django.db import IntegrityError, transaction
|
||||
|
||||
from ..models import Project, Grant, GrantReport
|
||||
from ..factories import ProjectFactory, GrantFactory, GrantReportFactory
|
||||
from .factories import ProjectFactory, GrantFactory, GrantReportFactory
|
||||
|
||||
|
||||
class ProjectTestCase(TestCase):
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
from factory import DjangoModelFactory, Sequence, SubFactory
|
||||
from factory.fuzzy import FuzzyText, FuzzyChoice, FuzzyInteger
|
||||
|
||||
from .models import Species, TrapSpecies, CollectionSpecies
|
||||
from ..collections_ccdb.factories import (CollectionFactory,
|
||||
from ..models import Species, TrapSpecies, CollectionSpecies
|
||||
from ccdb.collections_ccdb.tests.factories import (CollectionFactory,
|
||||
CollectionTrapFactory)
|
||||
|
||||
|
|
@ -2,7 +2,7 @@ from django.test import TestCase
|
|||
from django.db import IntegrityError, transaction
|
||||
|
||||
from ..models import Species, TrapSpecies, CollectionSpecies
|
||||
from ..factories import (SpeciesFactory, TrapSpeciesFactory,
|
||||
from .factories import (SpeciesFactory, TrapSpeciesFactory,
|
||||
CollectionSpeciesFactory)
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from factory import DjangoModelFactory, Sequence
|
||||
|
||||
from .models import User
|
||||
from ..models import User
|
||||
|
||||
|
||||
class UserFactory(DjangoModelFactory):
|
|
@ -2,7 +2,7 @@ from django.test import TestCase
|
|||
from django.db import IntegrityError, transaction
|
||||
|
||||
from ..models import User
|
||||
from ..factories import UserFactory
|
||||
from .factories import UserFactory
|
||||
|
||||
|
||||
class UserTestCase(TestCase):
|
||||
|
|
Loading…
Add table
Reference in a new issue