Skip to content

Commit

Permalink
[PERF-322] Moving shared_program from factory to client (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
JBrenesSimpat authored Dec 20, 2023
1 parent e35ebdc commit f0cfa0d
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
from edfi_performance_test.api.client.school import SchoolClient
from edfi_performance_test.factories.utils import RandomSuffixAttribute, formatted_date
from edfi_performance_test.api.client.parent import ParentClient
from edfi_performance_test.api.client.program import ProgramClient
from edfi_performance_test.factories.descriptors.utils import (
build_descriptor,
)


class StudentParentAssociationClient(EdFiAPIClient):
Expand Down Expand Up @@ -487,9 +491,14 @@ class StudentCTEProgramAssociationClient(EdFiAPIClient):
def create_with_dependencies(self, **kwargs):
# Prepopulated student
studentUniqueId = kwargs.pop("studentUniqueId", StudentClient.shared_student_id())
program = ProgramClient.shared_program_name()

return self.create_using_dependencies(
studentReference__studentUniqueId=studentUniqueId,
programReference__programName=program,
programReference__programTypeDescriptor=build_descriptor(
"ProgramType", program
),
**kwargs
)

Expand Down Expand Up @@ -578,10 +587,15 @@ class StudentHomelessProgramAssociationClient(EdFiAPIClient):
def create_with_dependencies(self, **kwargs):
# Prepopulated student
studentUniqueId = kwargs.pop("studentUniqueId", StudentClient.shared_student_id())
program = ProgramClient.shared_program_name()

# Create student academic record
return self.create_using_dependencies(
studentReference__studentUniqueId=studentUniqueId,
programReference__programName=program,
programReference__programTypeDescriptor=build_descriptor(
"ProgramType", program
),
**kwargs
)

Expand Down Expand Up @@ -642,10 +656,15 @@ class StudentLanguageInstructionProgramAssociationClient(EdFiAPIClient):
def create_with_dependencies(self, **kwargs):
# Prepopulated student
studentUniqueId = kwargs.pop("studentUniqueId", StudentClient.shared_student_id())
program = ProgramClient.shared_program_name()

# Create student academic record
return self.create_using_dependencies(
studentReference__studentUniqueId=studentUniqueId,
programReference__programName=program,
programReference__programTypeDescriptor=build_descriptor(
"ProgramType", program
),
**kwargs
)

Expand Down Expand Up @@ -688,10 +707,15 @@ class StudentMigrantEducationProgramAssociationClient(EdFiAPIClient):
def create_with_dependencies(self, **kwargs):
# Prepopulated student
studentUniqueId = kwargs.pop("studentUniqueId", StudentClient.shared_student_id())
program = ProgramClient.shared_program_name()

# Create student academic record
return self.create_using_dependencies(
studentReference__studentUniqueId=studentUniqueId,
programReference__programName=program,
programReference__programTypeDescriptor=build_descriptor(
"ProgramType", program
),
**kwargs
)

Expand All @@ -702,10 +726,15 @@ class StudentNeglectedOrDelinquentProgramAssociationClient(EdFiAPIClient):
def create_with_dependencies(self, **kwargs):
# Prepopulated student
studentUniqueId = kwargs.pop("studentUniqueId", StudentClient.shared_student_id())
program = ProgramClient.shared_program_name()

# Create student academic record
return self.create_using_dependencies(
studentReference__studentUniqueId=studentUniqueId,
programReference__programName=program,
programReference__programTypeDescriptor=build_descriptor(
"ProgramType", program
),
**kwargs
)

Expand All @@ -716,10 +745,15 @@ class StudentProgramAttendanceEventClient(EdFiAPIClient):
def create_with_dependencies(self, **kwargs):
# Prepopulated student
studentUniqueId = kwargs.pop("studentUniqueId", StudentClient.shared_student_id())
program = ProgramClient.shared_program_name()

# Create student academic record
return self.create_using_dependencies(
studentReference__studentUniqueId=studentUniqueId,
programReference__programName=program,
programReference__programTypeDescriptor=build_descriptor(
"ProgramType", program
),
**kwargs
)

Expand All @@ -730,10 +764,15 @@ class StudentSchoolFoodServiceProgramAssociationClient(EdFiAPIClient):
def create_with_dependencies(self, **kwargs):
# Prepopulated student
studentUniqueId = kwargs.pop("studentUniqueId", StudentClient.shared_student_id())
program = ProgramClient.shared_program_name()

# Create student academic record
return self.create_using_dependencies(
studentReference__studentUniqueId=studentUniqueId,
programReference__programName=program,
programReference__programTypeDescriptor=build_descriptor(
"ProgramType", program
),
**kwargs
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
from edfi_performance_test.api.client.v5.contact import ContactClient
from edfi_performance_test.api.client.school import SchoolClient
from edfi_performance_test.api.client.student import StudentClient
from edfi_performance_test.api.client.program import ProgramClient
from edfi_performance_test.factories.descriptors.utils import (
build_descriptor,
)


class StudentContactAssociationClient(EdFiAPIClient):
Expand Down Expand Up @@ -68,6 +72,7 @@ class StudentSpecialEducationProgramEligibilityAssociationClient(EdFiAPIClient):

def create_with_dependencies(self, **kwargs):
school_id = kwargs.pop("schoolId", SchoolClient.shared_elementary_school_id())
program = ProgramClient.shared_program_name()

# Create enrolled student
student_reference = self.student_client.create_with_dependencies(
Expand All @@ -80,5 +85,9 @@ def create_with_dependencies(self, **kwargs):
studentReference__studentUniqueId=student_reference["attributes"][
"studentUniqueId"
],
programReference__programName=program,
programReference__programTypeDescriptor=build_descriptor(
"ProgramType", program
),
**kwargs
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import factory

from edfi_performance_test.api.client.education import LocalEducationAgencyClient
from edfi_performance_test.api.client.program import ProgramClient
from edfi_performance_test.api.client.school import SchoolClient
from edfi_performance_test.factories.resources.api_factory import APIFactory
from edfi_performance_test.factories.descriptors.utils import build_descriptor
Expand Down Expand Up @@ -358,10 +357,8 @@ class StudentCTEProgramAssociationFactory(APIFactory):
programReference = factory.Dict(
dict(
educationOrganizationId=LocalEducationAgencyClient.shared_education_organization_id(),
programTypeDescriptor=build_descriptor(
"ProgramType", ProgramClient.shared_program_name()
),
programName=ProgramClient.shared_program_name(),
programTypeDescriptor=None,
programName=None,
)
) # Prepopulated program
beginDate = RandomDateAttribute()
Expand Down Expand Up @@ -416,10 +413,8 @@ class StudentHomelessProgramAssociationFactory(APIFactory):
programReference = factory.Dict(
dict(
educationOrganizationId=LocalEducationAgencyClient.shared_education_organization_id(),
programTypeDescriptor=build_descriptor(
"ProgramType", ProgramClient.shared_program_name()
),
programName=ProgramClient.shared_program_name(),
programTypeDescriptor=None,
programName=None,
)
) # Prepopulated program
studentReference = factory.Dict(
Expand Down Expand Up @@ -468,10 +463,8 @@ class StudentLanguageInstructionProgramAssociationFactory(APIFactory):
programReference = factory.Dict(
dict(
educationOrganizationId=LocalEducationAgencyClient.shared_education_organization_id(),
programTypeDescriptor=build_descriptor(
"ProgramType", ProgramClient.shared_program_name()
),
programName=ProgramClient.shared_program_name(),
programTypeDescriptor=None,
programName=None,
)
) # Prepopulated program
studentReference = factory.Dict(
Expand Down Expand Up @@ -510,10 +503,8 @@ class StudentMigrantEducationProgramAssociationFactory(APIFactory):
programReference = factory.Dict(
dict(
educationOrganizationId=LocalEducationAgencyClient.shared_education_organization_id(),
programTypeDescriptor=build_descriptor(
"ProgramType", ProgramClient.shared_program_name()
),
programName=ProgramClient.shared_program_name(),
programTypeDescriptor=None,
programName=None,
)
) # Prepopulated program
studentReference = factory.Dict(
Expand All @@ -533,10 +524,8 @@ class StudentNeglectedOrDelinquentProgramAssociationFactory(APIFactory):
programReference = factory.Dict(
dict(
educationOrganizationId=LocalEducationAgencyClient.shared_education_organization_id(),
programTypeDescriptor=build_descriptor(
"ProgramType", ProgramClient.shared_program_name()
),
programName=ProgramClient.shared_program_name(),
programTypeDescriptor=None,
programName=None,
)
) # Prepopulated program
studentReference = factory.Dict(
Expand All @@ -555,10 +544,8 @@ class StudentProgramAttendanceEventFactory(APIFactory):
programReference = factory.Dict(
dict(
educationOrganizationId=LocalEducationAgencyClient.shared_education_organization_id(),
programTypeDescriptor=build_descriptor(
"ProgramType", ProgramClient.shared_program_name()
),
programName=ProgramClient.shared_program_name(),
programTypeDescriptor=None,
programName=None,
)
) # Prepopulated program
studentReference = factory.Dict(
Expand All @@ -580,10 +567,8 @@ class StudentSchoolFoodServiceProgramAssociationFactory(APIFactory):
programReference = factory.Dict(
dict(
educationOrganizationId=LocalEducationAgencyClient.shared_education_organization_id(),
programTypeDescriptor=build_descriptor(
"ProgramType", ProgramClient.shared_program_name()
),
programName=ProgramClient.shared_program_name(),
programTypeDescriptor=None,
programName=None,
)
) # Prepopulated program
studentReference = factory.Dict(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
RandomDateAttribute
)
from edfi_performance_test.api.client.education import LocalEducationAgencyClient
from edfi_performance_test.api.client.program import ProgramClient


class StudentContactAssociationFactory(APIFactory):
Expand Down Expand Up @@ -50,10 +49,8 @@ class StudentSpecialEducationProgramEligibilityAssociationFactory(APIFactory):
programReference = factory.Dict(
dict(
educationOrganizationId=LocalEducationAgencyClient.shared_education_organization_id(),
programName=ProgramClient.shared_program_name(),
programTypeDescriptor=build_descriptor(
"ProgramType", ProgramClient.shared_program_name()
),
programName=None,
programTypeDescriptor=None,
)
)
studentReference = factory.Dict(
Expand Down

0 comments on commit f0cfa0d

Please sign in to comment.