aboutsummaryrefslogblamecommitdiffstats
path: root/ctrack/caf/tests/factories.py
blob: 7aaf7161b26e37f62b7aed4d2e0481085cfb531c (plain) (tree)
1
2
3
4
5
6
7
8
9
             
 
              

                         
                                                                                     
                                                                                   

 
                                             

                                                                                        
                                                                                       
               
                                                           

                                                               


                                                                                   




                   
                                                          
                                         
 
                                                              
                     

                                                                                   
                             
 
               
                                
 

                                                 


                                                                    




                                                                        

 
                                                   





                                                                             
                         




                                                      
                                                              

               
                            
import random

import factory
from factory import Faker

from ctrack.caf.models import ApplicableSystem, Grading, DocumentFile, FileStore, CAF
from ctrack.organisations.tests.factories import OrganisationFactory, PersonFactory


class CAFFactory(factory.DjangoModelFactory):
    quality_grading = factory.SubFactory("ctrack.caf.tests.factories.GradingFactory")
    confidence_grading = factory.SubFactory("ctrack.caf.tests.factories.GradingFactory")
    organisation = factory.SubFactory("ctrack.organisations.tests.OrganisationFactory")
    file = None
    version = Faker("bothify", text="??##", letters="ABCD")
    triage_review_date = Faker("date_object")
    triage_review_inspector = factory.SubFactory(PersonFactory)
    comments = Faker(
        "paragraph", nb_sentences=5, variable_nb_sentences=True, ext_word_list=None
    )

    class Meta:
        model = CAF


class ApplicableSystemFactory(factory.DjangoModelFactory):
    """Factory for Essential Services."""

    name = Faker("text", max_nb_chars=100, ext_word_list=None)
    function = Faker(
        "paragraph", nb_sentences=4, variable_nb_sentences=True, ext_word_list=None
    )
    dft_categorisation = "CR"

    class Meta:
        model = ApplicableSystem


class GradingFactory(factory.DjangoModelFactory):
    descriptor = factory.Iterator(
        ["Q1", "Q2", "Q3", "Q4", "Q5", "C1", "C2", "C3", "C4", "C5"]
    )
    description = Faker("text", max_nb_chars=100, ext_word_list=None)
    type = factory.Iterator(Grading.GRADING_TYPE, getter=lambda g: g[0])

    class Meta:
        model = Grading


class FileStoreFactory(factory.DjangoModelFactory):
    descriptor = "File Store X"
    virtual_location = Faker("street_name")
    physical_location = random.choice(["Cupboard A", "Tin Box", "The Vault"])
    physical_location_organisation = factory.SubFactory(OrganisationFactory)

    class Meta:
        model = FileStore


class DocumentFileFactory(factory.DjangoModelFactory):
    name = Faker("file_name", extension="xlsx")
    type = random.choice([1, 2, 3, 4])
    file_store_location = factory.SubFactory(FileStoreFactory)

    class Meta:
        model = DocumentFile