MAINT: Refactor, move factories into tests

This commit is contained in:
Matthew Ryan Dillon 2016-08-21 16:06:38 -07:00
parent 31714215d0
commit 02a21306fe
16 changed files with 49 additions and 42 deletions

View file

@ -4,11 +4,12 @@ from factory import DjangoModelFactory, Sequence, SubFactory, LazyFunction
from factory.fuzzy import FuzzyText, FuzzyDate, FuzzyInteger from factory.fuzzy import FuzzyText, FuzzyDate, FuzzyInteger
from factory.django import FileField from factory.django import FileField
from .models import CollectionType, CollectionMethod, Flaw, ADFGPermit, Collection, \ from ..models import (CollectionType, CollectionMethod, Flaw, ADFGPermit,
DatasheetAttachment, CollectionTrap Collection, DatasheetAttachment, CollectionTrap)
from ..projects.factories import ProjectFactory from ccdb.projects.tests.factories import ProjectFactory
from ..locations.factories import StudyLocationFactory, StorageLocationFactory from ccdb.locations.tests.factories import (StudyLocationFactory,
from ..processing.factories import ProcessTypeFactory, ReagentFactory StorageLocationFactory)
from ccdb.processing.tests.factories import ProcessTypeFactory, ReagentFactory
class CollectionTypeFactory(DjangoModelFactory): class CollectionTypeFactory(DjangoModelFactory):

View file

@ -1,11 +1,11 @@
from django.test import TestCase from django.test import TestCase
from django.db import IntegrityError, transaction from django.db import IntegrityError, transaction
from ..models import CollectionType, CollectionMethod, Flaw, ADFGPermit, \ from ..models import (CollectionType, CollectionMethod, Flaw, ADFGPermit,
Collection, DatasheetAttachment, CollectionTrap Collection, DatasheetAttachment, CollectionTrap)
from ..factories import CollectionTypeFactory, CollectionMethodFactory, \ from .factories import (CollectionTypeFactory, CollectionMethodFactory,
FlawFactory, ADFGPermitFactory, CollectionFactory, DatasheetAttachmentFactory, \ FlawFactory, ADFGPermitFactory, CollectionFactory,
CollectionTrapFactory DatasheetAttachmentFactory, CollectionTrapFactory)
class CollectionTypeTestCase(TestCase): class CollectionTypeTestCase(TestCase):

View file

@ -1,15 +1,15 @@
from datetime import date, time from datetime import date, time
from factory import DjangoModelFactory, Sequence, SubFactory, \ from factory import (DjangoModelFactory, Sequence, SubFactory, LazyFunction,
LazyFunction, post_generation post_generation)
from factory.fuzzy import FuzzyText, FuzzyDate, FuzzyInteger, FuzzyFloat from factory.fuzzy import FuzzyText, FuzzyDate, FuzzyInteger, FuzzyFloat
from factory.django import FileField from factory.django import FileField
from .models import Flaw, Experiment, ProtocolAttachment, TreatmentType, \ from ..models import (Flaw, Experiment, ProtocolAttachment, TreatmentType,
Treatment, TreatmentReplicate, AliveDeadCount Treatment, TreatmentReplicate, AliveDeadCount)
from ..misc.factories import ContainerFactory from ccdb.misc.tests.factories import ContainerFactory
from ..locations.factories import StudyLocationFactory from ccdb.locations.tests.factories import StudyLocationFactory
from ..species.factories import SpeciesFactory from ccdb.species.tests.factories import SpeciesFactory
class FlawFactory(DjangoModelFactory): class FlawFactory(DjangoModelFactory):

View file

@ -1,11 +1,12 @@
from django.test import TestCase from django.test import TestCase
from django.db import IntegrityError, transaction from django.db import IntegrityError, transaction
from ..models import Flaw, Experiment, ProtocolAttachment, TreatmentType, \ from ..models import (Flaw, Experiment, ProtocolAttachment, TreatmentType,
Treatment, TreatmentReplicate, AliveDeadCount Treatment, TreatmentReplicate, AliveDeadCount)
from ..factories import FlawFactory, ExperimentFactory, ProtocolAttachmentFactory, \ from .factories import (FlawFactory, ExperimentFactory,
TreatmentTypeFactory, TreatmentFactory, TreatmentReplicateFactory, \ ProtocolAttachmentFactory, TreatmentTypeFactory,
AliveDeadCountFactory TreatmentFactory, TreatmentReplicateFactory,
AliveDeadCountFactory)
class FlawTestCase(TestCase): class FlawTestCase(TestCase):

View file

@ -1,7 +1,8 @@
from factory import DjangoModelFactory, Sequence, SubFactory from factory import DjangoModelFactory, Sequence, SubFactory
from factory.fuzzy import FuzzyText, FuzzyChoice, FuzzyInteger 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): class RegionFactory(DjangoModelFactory):

View file

@ -1,9 +1,10 @@
from django.test import TestCase from django.test import TestCase
from django.db import IntegrityError, transaction from django.db import IntegrityError, transaction
from ..models import Region, Site, MunicipalLocation, StudyLocation, StorageLocation from ..models import (Region, Site, MunicipalLocation, StudyLocation,
from ..factories import RegionFactory, SiteFactory, MunicipalLocationFactory, \ StorageLocation)
StudyLocationFactory, StorageLocationFactory from .factories import (RegionFactory, SiteFactory, MunicipalLocationFactory,
StudyLocationFactory, StorageLocationFactory)
class RegionTestCase(TestCase): class RegionTestCase(TestCase):

View file

@ -1,6 +1,7 @@
import factory import factory
from .models import MeasurementUnit, MeasurementType, Material, Color, Container from ..models import (MeasurementUnit, MeasurementType, Material, Color,
Container)
class MeasurementUnitFactory(factory.DjangoModelFactory): class MeasurementUnitFactory(factory.DjangoModelFactory):

View file

@ -1,9 +1,10 @@
from django.test import TestCase from django.test import TestCase
from django.db import IntegrityError, transaction from django.db import IntegrityError, transaction
from ..models import MeasurementUnit, MeasurementType, Material, Color, Container from ..models import (MeasurementUnit, MeasurementType, Material, Color,
from ..factories import MeasurementUnitFactory, MeasurementTypeFactory, \ Container)
MaterialFactory, ColorFactory, ContainerFactory from .factories import (MeasurementUnitFactory, MeasurementTypeFactory,
MaterialFactory, ColorFactory, ContainerFactory)
class MeasurementUnitTestCase(TestCase): class MeasurementUnitTestCase(TestCase):

View file

@ -3,8 +3,8 @@ from datetime import datetime, date
from factory import DjangoModelFactory, Sequence, SubFactory, LazyFunction from factory import DjangoModelFactory, Sequence, SubFactory, LazyFunction
from factory.fuzzy import FuzzyText, FuzzyDate, FuzzyFloat, FuzzyInteger from factory.fuzzy import FuzzyText, FuzzyDate, FuzzyFloat, FuzzyInteger
from .models import ProcessType, Reagent, Flaw, Processing from ..models import ProcessType, Reagent, Flaw, Processing
from ..misc.factories import ContainerFactory, MeasurementUnitFactory from ccdb.misc.tests.factories import ContainerFactory, MeasurementUnitFactory
class ProcessTypeFactory(DjangoModelFactory): class ProcessTypeFactory(DjangoModelFactory):

View file

@ -2,7 +2,8 @@ from django.test import TestCase
from django.db import IntegrityError, transaction from django.db import IntegrityError, transaction
from ..models import ProcessType, Reagent, Flaw, Processing from ..models import ProcessType, Reagent, Flaw, Processing
from ..factories import ProcessTypeFactory, ReagentFactory, FlawFactory, ProcessingFactory from .factories import (ProcessTypeFactory, ReagentFactory, FlawFactory,
ProcessingFactory)
class ProcessTypeTestCase(TestCase): class ProcessTypeTestCase(TestCase):

View file

@ -2,7 +2,7 @@ from datetime import datetime
import factory import factory
from .models import Project, Grant, GrantReport from ..models import Project, Grant, GrantReport
class ProjectFactory(factory.DjangoModelFactory): class ProjectFactory(factory.DjangoModelFactory):

View file

@ -2,7 +2,7 @@ from django.test import TestCase
from django.db import IntegrityError, transaction from django.db import IntegrityError, transaction
from ..models import Project, Grant, GrantReport from ..models import Project, Grant, GrantReport
from ..factories import ProjectFactory, GrantFactory, GrantReportFactory from .factories import ProjectFactory, GrantFactory, GrantReportFactory
class ProjectTestCase(TestCase): class ProjectTestCase(TestCase):

View file

@ -1,9 +1,9 @@
from factory import DjangoModelFactory, Sequence, SubFactory from factory import DjangoModelFactory, Sequence, SubFactory
from factory.fuzzy import FuzzyText, FuzzyChoice, FuzzyInteger from factory.fuzzy import FuzzyText, FuzzyChoice, FuzzyInteger
from .models import Species, TrapSpecies, CollectionSpecies from ..models import Species, TrapSpecies, CollectionSpecies
from ..collections_ccdb.factories import (CollectionFactory, from ccdb.collections_ccdb.tests.factories import (CollectionFactory,
CollectionTrapFactory) CollectionTrapFactory)
class SpeciesFactory(DjangoModelFactory): class SpeciesFactory(DjangoModelFactory):

View file

@ -2,8 +2,8 @@ from django.test import TestCase
from django.db import IntegrityError, transaction from django.db import IntegrityError, transaction
from ..models import Species, TrapSpecies, CollectionSpecies from ..models import Species, TrapSpecies, CollectionSpecies
from ..factories import (SpeciesFactory, TrapSpeciesFactory, from .factories import (SpeciesFactory, TrapSpeciesFactory,
CollectionSpeciesFactory) CollectionSpeciesFactory)
class SpeciesTestCase(TestCase): class SpeciesTestCase(TestCase):

View file

@ -1,6 +1,6 @@
from factory import DjangoModelFactory, Sequence from factory import DjangoModelFactory, Sequence
from .models import User from ..models import User
class UserFactory(DjangoModelFactory): class UserFactory(DjangoModelFactory):

View file

@ -2,7 +2,7 @@ from django.test import TestCase
from django.db import IntegrityError, transaction from django.db import IntegrityError, transaction
from ..models import User from ..models import User
from ..factories import UserFactory from .factories import UserFactory
class UserTestCase(TestCase): class UserTestCase(TestCase):