コード例 #1
0
ファイル: diagnostic.py プロジェクト: betagouv/ma-cantine
class DiagnosticFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = Diagnostic

    canteen = factory.SubFactory(CanteenFactory)
    year = factory.Faker("year")

    value_bio_ht = factory.Faker("random_int", min=0, max=2000)
    value_sustainable_ht = factory.Faker("random_int", min=0, max=2000)
    value_total_ht = factory.Faker("random_int", min=6000, max=10000)

    has_waste_diagnostic = factory.Faker("boolean")
    has_waste_plan = factory.Faker("boolean")
    waste_actions = factory.List(
        random.sample(list(Diagnostic.WasteActions), random.randint(0, 2)))
    has_donation_agreement = factory.Faker("boolean")

    has_diversification_plan = factory.Faker("boolean")
    vegetarian_weekly_recurrence = fuzzy.FuzzyChoice(
        list(Diagnostic.MenuFrequency))
    vegetarian_menu_type = fuzzy.FuzzyChoice(list(Diagnostic.MenuType))

    cooking_plastic_substituted = factory.Faker("boolean")
    serving_plastic_substituted = factory.Faker("boolean")
    plastic_bottles_substituted = factory.Faker("boolean")
    plastic_tableware_substituted = factory.Faker("boolean")

    communication_supports = factory.List(
        random.sample(list(Diagnostic.CommunicationType), random.randint(0,
                                                                         2)))
    communication_support_url = factory.Faker("uri")
    communicates_on_food_plan = factory.Faker("boolean")
コード例 #2
0
class StaffFactory(APIFactory):
    staffUniqueId = UniqueIdAttribute()
    firstName = "John"
    middleName = ""
    lastSurname = "Loyo"
    hispanicLatinoEthnicity = True
    birthDate = "1959-04-30"
    generationCodeSuffix = "Sr"
    highestCompletedLevelOfEducationDescriptor = build_descriptor(
        'LevelOfEducationDescriptor', 'Master\'s')
    highlyQualifiedTeacher = True
    personalTitlePrefix = "Mr"
    sexDescriptor = build_descriptor('Sex', 'Male')
    electronicMails = factory.List([
        dict(
            electronicMailAddress="*****@*****.**",
            electronicMailTypeDescriptor=build_descriptor(
                'ElectronicMailType', 'Work'),
        ),
    ])
    identificationCodes = factory.LazyAttribute(
        lambda o: build_descriptor_dicts('staffIdentificationSystem', [(
            'State', {
                'identificationCode': o.staffUniqueId
            })]))
    races = factory.List([
        dict(raceDescriptor=build_descriptor('Race', 'White'), ),
    ])
コード例 #3
0
class DisciplineActionFactory(APIFactory):
    disciplineActionIdentifier = UniqueIdAttribute(num_chars=20)
    disciplineDate = formatted_date(9, 20)
    disciplines = factory.List([
        factory.Dict(
            dict(disciplineDescriptor=build_descriptor(
                'Discipline', 'Out of School Suspension'))),
    ])
    studentReference = factory.Dict(dict(
        studentUniqueId=111111))  # Default value for scenarios, but not in DB
    actualDisciplineActionLength = 2
    studentDisciplineIncidentAssociations = factory.List([
        factory.Dict(
            dict(
                studentDisciplineIncidentAssociationReference=factory.Dict(
                    dict(
                        incidentIdentifier=None,  # Must be entered by user
                        schoolId=SchoolClient.shared_elementary_school_id(
                        ),  # Prepopulated school
                        studentUniqueId=
                        111111,  # Default value for scenarios, but not in DB
                    )), ), ),
    ])
    responsibilitySchoolReference = factory.Dict(
        dict(schoolId=SchoolClient.shared_elementary_school_id())
    )  # Prepopulated school
コード例 #4
0
class StudentAssessmentFactory(APIFactory):
    studentAssessmentIdentifier = UniqueIdAttribute()
    studentReference = factory.Dict(dict(studentUniqueId=StudentClient.shared_student_id()))  # Prepopulated student
    assessmentReference = factory.Dict(
        dict(
            assessmentIdentifier=None,
            namespace='uri://ed-fi.org/Assessment/Assessment.xml'
        )
    )
    administrationDate = RandomDateAttribute()  # Along with studentReference and assessmentReference, this is the PK
    administrationEnvironmentDescriptor = build_descriptor('AdministrationEnvironment', 'Testing Center')
    administrationLanguageDescriptor = build_descriptor('Language', 'eng')
    serialNumber = "0"
    whenAssessedGradeLevelDescriptor = build_descriptor('GradeLevel', 'Sixth grade')
    performanceLevels = factory.List([
        factory.Dict(
            dict(
                assessmentReportingMethodDescriptor=build_descriptor('AssessmentReportingMethod', 'Scale score'),
                performanceLevelDescriptor=build_descriptor('PerformanceLevel', 'Fail'),
                performanceLevelMet=True,
            )
        ),
    ])
    scoreResults = factory.List([
        factory.Dict(
            dict(
                assessmentReportingMethodDescriptor=build_descriptor('AssessmentReportingMethod', 'Scale score'),
                result="25",
                resultDatatypeTypeDescriptor=build_descriptor('ResultDatatypeType', 'Integer'),
            )
        )
    ])
コード例 #5
0
class QueryOptionFactory(factory.mongoengine.MongoEngineFactory):

    class Meta:
        model = QueryOption

    data_source_id = factory.LazyAttribute(lambda o: utils.generate_id('ds'))
    resource_type = 'identity.Project'
    query = {
        'aggregate': {
            'group': {
                'keys': [{
                    'key': 'project_id',
                    'name': 'project_id'
                }, {
                    'key': 'name',
                    'name': 'project_name'
                }, {
                    'key': 'project_group.name',
                    'name': 'project_group_name'
                }],
            }
        },
        'sort': {
            'name': 'resource_count',
            'desc': True
        },
        'page': {
            'limit': 5
        }
    }
    join = factory.List([factory.SubFactory(JoinQueryFactory)])
    formulas = factory.List([factory.SubFactory(FormulaFactory)])
コード例 #6
0
class UsersUserUdmObjectFactory(factory.Factory):
    class Meta:
        model = udm_rest_client.base_http.UdmObject

    dn = ""
    uri = factory.Faker("url")
    uuid = factory.Faker("uuid4")
    options = factory.List([factory.Faker("user_name")])
    policies = factory.List([factory.Faker("user_name")])
    superordinate = None
    position = ""
    props = factory.Dict({})

    @classmethod
    def _create(cls, model_class, user_data: User, *args, **kwargs):
        obj = model_class()
        for k, v in kwargs.items():
            setattr(obj, k, v)
        obj._udm_module = udm_rest_client.base_http.UdmModule(
            "users/user",
            udm_rest_client.base_http.Session("username", "password", "url"),
        )
        obj.position = user_data.position
        obj.dn = user_data.dn
        obj.props = user_data.props
        return obj
コード例 #7
0
class OrderRequestFactory(factory.Factory):
    class Meta:
        model = KondutoOrderRequest

    id = lazy_attribute(lambda o: uuid.uuid4())
    visitor = lazy_attribute(lambda o: uuid.uuid4())
    customer = SubFactory(CustomerFactory)
    payment = factory.List(
        [factory.SubFactory(PaymentFactory) for _ in range(2)])
    billing = SubFactory(AddressFactory)
    shipping = SubFactory(AddressFactory)
    shopping_cart = factory.List(
        [factory.SubFactory(ProductFactory) for _ in range(2)])
    total_amount = lazy_attribute(
        lambda o: fake.pydecimal(left_digits=2, right_digits=4, positive=True))
    shipping_amount = lazy_attribute(
        lambda o: fake.pydecimal(left_digits=2, right_digits=4, positive=True))
    tax_amount = lazy_attribute(
        lambda o: fake.pydecimal(left_digits=2, right_digits=4, positive=True))
    currency = lazy_attribute(lambda o: fake.currency_code())
    installments = lazy_attribute(
        lambda o: fake.pyint(min_value=1, max_value=12, step=1))
    ip = lazy_attribute(
        lambda o: fake.ipv4(network=False, address_class=None, private=None))
    first_message = lazy_attribute(
        lambda o: fake.date_time(tzinfo=None, end_datetime=None))
    messages_exchanged = lazy_attribute(
        lambda o: fake.pyint(min_value=0, max_value=9999, step=5))
    purchased_at = lazy_attribute(
        lambda o: fake.date_time(tzinfo=None, end_datetime=None))
    seller = SubFactory(SellerFactory)
コード例 #8
0
class HorizontalExecutionFactory(factory.Factory):
    class Meta:
        model = cuir.HorizontalExecution

    body = factory.List([factory.SubFactory(AssignStmtFactory)])
    declarations = factory.List([])
    extent = factory.SubFactory(IJExtentFactory)
コード例 #9
0
class VerticalLoopFactory(factory.Factory):
    class Meta:
        model = cuir.VerticalLoop

    loop_order = cuir.LoopOrder.PARALLEL
    sections = factory.List([factory.SubFactory(VerticalLoopSectionFactory)])
    ij_caches = factory.List([])
    k_caches = factory.List([])
コード例 #10
0
class AssessmentFactory(APIFactory):
    assessmentIdentifier = UniqueIdAttribute()
    academicSubjects = factory.List([
        factory.Dict(
            dict(
                academicSubjectDescriptor=build_descriptor('AcademicSubject', 'English')
            )
        )
    ])
    assessedGradeLevels = factory.List([
        factory.Dict(
            dict(
                gradeLevelDescriptor=build_descriptor('GradeLevel', 'Twelfth grade')
            )
        )
    ])
    assessmentTitle = RandomSuffixAttribute("AP - English")
    assessmentVersion = 2017
    maxRawScore = 25
    namespace = 'uri://ed-fi.org/Assessment/Assessment.xml'
    identificationCodes = factory.List([
        factory.Dict(
            dict(
                assessmentIdentificationSystemDescriptor=build_descriptor(
                    'AssessmentIdentificationSystem', 'Test Contractor'),
                identificationCode="AP English",
            )
        ),
    ])
    performanceLevels = factory.List([
        factory.Dict(
            dict(
                assessmentReportingMethodDescriptor=build_descriptor('AssessmentReportingMethod', 'Scale score'),
                performanceLevelDescriptor=build_descriptor('PerformanceLevel', 'Pass'),
                maximumScore="25",
                minimumScore="12",
            )
        ),
        factory.Dict(
            dict(
                assessmentReportingMethodDescriptor=build_descriptor('AssessmentReportingMethod', 'Scale score'),
                performanceLevelDescriptor=build_descriptor('PerformanceLevel', 'Fail'),
                maximumScore="11",
                minimumScore="0",
            )
        ),
    ])
    scores = factory.List([
        factory.Dict(
            dict(
                assessmentReportingMethodDescriptor=build_descriptor('AssessmentReportingMethod', 'Scale score'),
                resultDatatypeType="Integer",
                maximumScore="25",
                minimumScore="0",
            )
        ),
    ])
コード例 #11
0
ファイル: factories.py プロジェクト: shivank-gupta/vyked
class ServiceFactory(factory.DictFactory):
    service = factory.Sequence(lambda n: "service_%d" % n)
    version = "1.0.0"
    dependencies = factory.List([])
    events = factory.List([])
    host = factory.Sequence(lambda n: "192.168.0.%d" % n)
    port = factory.Sequence(lambda n: 4000 + n)
    node_id = factory.Sequence(lambda n: "node_%d" % n)
    type = 'tcp'
コード例 #12
0
class ProgramFactory(factory.Factory):
    class Meta:
        model = cuir.Program

    name = identifier(cuir.Program)
    params = undefined_symbol_list(lambda name: FieldDeclFactory(name=name),
                                   "kernels", "temporaries")
    temporaries = factory.List([])
    kernels = factory.List([factory.SubFactory(KernelFactory)])
コード例 #13
0
class VerticalPassFactory(factory.Factory):
    class Meta:
        model = npir.VerticalPass

    temp_defs = factory.List(
        [factory.SubFactory(VectorAssignFactory, temp_init=True)])
    body = factory.List([factory.SubFactory(VectorAssignFactory)])
    lower = common.AxisBound.start()
    upper = common.AxisBound.end()
    direction = common.LoopOrder.PARALLEL
コード例 #14
0
ファイル: factories.py プロジェクト: etcaterva/eas-backend
class LinkFactory(BaseDrawFactory):
    class Meta:
        model = "api.Link"

    items_set1 = fb.List(["paco1", "gloria1", "pepe1"])
    items_set2 = fb.List(["david2", "pedro2", "jose2"])

    @classmethod
    def dict(cls, **kwargs):
        """Returns a dict rather than an object"""
        return fb.build(dict, FACTORY_CLASS=cls, **kwargs)
コード例 #15
0
class SchoolClassFactory(factory.Factory):
    class Meta:
        model = TestSchoolClass

    name = factory.LazyFunction(lambda: f"test.{fake.user_name()}")
    school = "DEMOSCHOOL"
    description = factory.Faker("text", max_nb_chars=50)
    users = factory.List([])
    ucsschool_roles = factory.List([])
    dn = ""
    url = ""
コード例 #16
0
ファイル: __init__.py プロジェクト: vivekanand1101/pontoon
class VCSEntityFactory(factory.Factory):
    resource = None
    key = 'key'
    string = 'string'
    string_plural = ''
    comments = factory.List([])
    source = factory.List([])
    order = Sequence(lambda n: n)

    class Meta:
        model = VCSEntity
コード例 #17
0
class VCSEntityFactory(factory.Factory):
    resource = None
    key = "key"
    string = "string"
    string_plural = ""
    comments = factory.List([])
    source = factory.List([])
    order = factory.Sequence(lambda n: n)

    class Meta:
        model = VCSEntity
コード例 #18
0
class ProgramFactory(factory.Factory):
    class Meta:
        model = cuir.Program

    name = identifier(cuir.Program)
    params = undefined_symbol_list(lambda name: FieldDeclFactory(name=name),
                                   "kernels", "temporaries")
    positionals: List[cuir.Positional] = []
    temporaries = factory.List([])
    kernels = factory.List([factory.SubFactory(KernelFactory)])
    axis_sizes = cuir.axis_size_decls()
コード例 #19
0
ファイル: gordo.py プロジェクト: vishalbelsare/latigo
class MachineDatasetFactory(factory.Factory):
    train_start_date = factory.fuzzy.FuzzyDateTime(
        datetime(2020, 2, 20, 10, 0, tzinfo=timezone.utc),
        datetime(2020, 2, 20, 10, 30, tzinfo=timezone.utc),
    )
    train_end_date = factory.fuzzy.FuzzyDateTime(
        datetime(2020, 4, 20, 11, 0, tzinfo=timezone.utc),
        datetime(2020, 4, 20, 11, 30, tzinfo=timezone.utc),
    )
    tag_list = factory.List("GRA-QTR1-13-0853.PV" for _ in range(3))
    target_tag_list = factory.List("GRA-QTR1-13-0853.PV" for _ in range(3))

    class Meta:
        model = dict
コード例 #20
0
class BookFactory(SQLAFactory):
    class Meta:
        model = Book

    name = factory.LazyFunction(faker.word)

    description = factory.LazyFunction(faker.sentence)

    content = factory.LazyFunction(faker.sentence)

    authors = factory.List(
        [factory.SubFactory(AuthorFactory) for _ in range(2)])

    readers = factory.List(
        [factory.SubFactory(ReaderFactory) for _ in range(2)])
コード例 #21
0
class LearningStandardFactory(APIFactory):
    learningStandardId = UniqueIdAttribute()
    academicSubjects = factory.List([
        factory.Dict(
            dict(academicSubjectDescriptor=build_descriptor('AcademicSubject', 'Mathematics'))
        )
    ])
    courseTitle = "Advanced Math for students v4.4"
    description = "Unit 1 Advanced Math for students v4.4"
    namespace = 'uri://ed-fi.org/LearningStandard/LearningStandard.xml'
    gradeLevels = factory.List([
        factory.Dict(
            dict(gradeLevelDescriptor=build_descriptor('GradeLevel', 'Tenth grade'))
        ),
    ])
コード例 #22
0
class StaffSchoolAssociationFactory(APIFactory):
    staffReference = factory.Dict(
        dict(staffUniqueId=StaffClient.shared_staff_id())
    )  # Prepopulated staff record
    schoolReference = factory.Dict(
        dict(schoolId=SchoolClient.shared_elementary_school_id())
    )  # Prepopulated school record
    academicSubjects = factory.List([
        dict(academicSubjectDescriptor=build_descriptor(
            'AcademicSubject', 'English Language Arts')),
    ])
    gradeLevels = factory.List(
        [])  # Default grade levels are blank for scenario
    programAssignmentDescriptor = build_descriptor(
        'ProgramAssignment', 'Other')  # Required despite "optional" in docs
コード例 #23
0
class PartyFactory(BaseFactory):
    class Meta:
        model = Party

    class Params:
        person = factory.Trait(
            first_name=factory.Faker('first_name'),
            party_name=factory.Faker('last_name'),
            email=factory.LazyAttribute(lambda o: f'{o.first_name}.{o.party_name}@example.com'),
            party_type_code='PER',
        )

        company = factory.Trait(
            party_name=factory.Faker('company'),
            email=factory.Faker('company_email'),
            party_type_code='ORG',
        )

    party_guid = factory.LazyFunction(uuid.uuid4)
    first_name = None
    party_name = None
    phone_no = factory.Faker('numerify', text='###-###-####')
    phone_ext = factory.Iterator([None, '123'])
    email = None
    effective_date = TODAY
    expiry_date = None
    party_type_code = None

    mine_party_appt = []
    address = factory.List([factory.SubFactory(AddressFactory) for _ in range(1)])
コード例 #24
0
ファイル: oir_utils.py プロジェクト: stubbiali/gt4py
class VerticalLoopFactory(factory.Factory):
    class Meta:
        model = oir.VerticalLoop

    loop_order = common.LoopOrder.PARALLEL
    sections = factory.List([factory.SubFactory(VerticalLoopSectionFactory)])
    caches: List[oir.CacheDesc] = []
コード例 #25
0
ファイル: oir_utils.py プロジェクト: havogt/gt4py
class VerticalLoopSectionFactory(factory.Factory):
    class Meta:
        model = oir.VerticalLoopSection

    interval = factory.SubFactory(IntervalFactory)
    horizontal_executions = factory.List(
        [factory.SubFactory(HorizontalExecutionFactory)])
コード例 #26
0
class SectionFactory(APIFactory):
    educationalEnvironmentDescriptor = build_descriptor(
        "EducationalEnvironment", "Classroom")
    sectionIdentifier = RandomSuffixAttribute("ELA012017RM555")
    availableCredits = 1
    sequenceOfCourse = 1
    classPeriods = factory.List([
        factory.Dict(
            dict(
                classPeriodReference=factory.Dict(
                    dict(classPeriodName=None  # Must be entered by client
                         )), ), ),
    ])
    courseOfferingReference = factory.Dict(
        dict(
            localCourseCode=
            "ELA-01",  # Will need to override this with reference value
            schoolId=SchoolClient.shared_elementary_school_id(),
            schoolYear=2014,
            sessionName=
            "2016-2017 Fall Semester",  # Will need to override this with reference value
        ))
    locationReference = factory.Dict(
        dict(
            schoolId=SchoolClient.shared_elementary_school_id(),
            classroomIdentificationCode=
            "501",  # Will need to override this with reference value
        ))
コード例 #27
0
class SchoolFactory(APIFactory):
    schoolId = UniquePrimaryKeyAttribute()
    shortNameOfInstitution = RandomSuffixAttribute("GOHS")
    nameOfInstitution = factory.LazyAttribute(
        lambda o: "Grand Oaks High School {}".format(o.shortNameOfInstitution[
            -4:]))
    addresses = factory.List([
        factory.SubFactory(AddressFactory),
    ])
    educationOrganizationCategories = ListOfDescriptors(
        'EducationOrganizationCategory', ['School'])
    educationOrganizationCodes = factory.LazyAttribute(
        lambda o: build_descriptor_dicts(
            'EducationOrganizationIdentificationSystem', [('SEA', {
                'identificationCode':
                str(o.schoolId)
            })]))
    gradeLevels = ListOfDescriptors(
        'GradeLevel',
        ['Ninth grade', 'Tenth grade', 'Eleventh grade', 'Twelfth grade'])
    institutionTelephones = ListOfDescriptors(
        'InstitutionTelephoneNumberType', [('Main', {
            'telephoneNumber': '(950) 325-9465'
        })])
    localEducationAgencyReference = {
        'localEducationAgencyId':
        LocalEducationAgencyClient.shared_education_organization_id(),
    }
コード例 #28
0
ファイル: gtcpp_utils.py プロジェクト: havogt/gt4py
class GTApplyMethodFactory(factory.Factory):
    class Meta:
        model = gtcpp.GTApplyMethod

    interval = factory.SubFactory(GTIntervalFactory)
    body = factory.List([factory.SubFactory(AssignStmtFactory)])
    local_variables: List[gtcpp.LocalVarDecl] = []
コード例 #29
0
ファイル: gtcpp_utils.py プロジェクト: havogt/gt4py
class GTComputationCallFactory(factory.Factory):
    class Meta:
        model = gtcpp.GTComputationCall

    arguments: List[gtcpp.Arg] = []
    multi_stages = factory.List([factory.SubFactory(GTMultiStageFactory)])
    temporaries = undefined_symbol_list(lambda name: TemporaryFactory(name=name), "multi_stages")
コード例 #30
0
ファイル: gtcpp_utils.py プロジェクト: havogt/gt4py
class GTMultiStageFactory(factory.Factory):
    class Meta:
        model = gtcpp.GTMultiStage

    loop_order = common.LoopOrder.PARALLEL
    stages = factory.List([factory.SubFactory(GTStageFactory)])
    caches: List[gtcpp.IJCache] = []