Refact: change fakes creation functions
This commit is contained in:
parent
4f4fc53253
commit
b50227a658
@ -8,12 +8,11 @@ from backend.model.tribe import Tribe
|
||||
faker = Faker()
|
||||
|
||||
|
||||
def build_tribes(quantity=1):
|
||||
def build_tribes(quantity: int = 1):
|
||||
return [Tribe(name=faker.words(5), level=faker.words(5)) for _ in range(quantity)]
|
||||
|
||||
|
||||
def build_tribe_assessment(tribe_qty=1, assessment_per_tribe=1):
|
||||
tribes = build_tribes(tribe_qty)
|
||||
def build_assessments(tribes: list[Tribe], assessment_per_tribe: int = 1):
|
||||
|
||||
assessments = []
|
||||
for t in tribes:
|
||||
@ -22,14 +21,10 @@ def build_tribe_assessment(tribe_qty=1, assessment_per_tribe=1):
|
||||
for _ in range(assessment_per_tribe)
|
||||
]
|
||||
|
||||
return tribes, assessments
|
||||
return assessments
|
||||
|
||||
|
||||
def build_tribe_assessment_exercise(
|
||||
tribe_qty=1, assessment_per_tribe=1, exercise_per_assessment=1
|
||||
):
|
||||
tribes, assessments = build_tribe_assessment(tribe_qty, assessment_per_tribe)
|
||||
|
||||
def build_exercises(assessments: list[Assessment], exercise_per_assessment=1):
|
||||
exercises = []
|
||||
for assessment in assessments:
|
||||
exercises += [
|
||||
@ -37,7 +32,7 @@ def build_tribe_assessment_exercise(
|
||||
for _ in range(exercise_per_assessment)
|
||||
]
|
||||
|
||||
return tribes, assessments, exercises
|
||||
return exercises
|
||||
|
||||
|
||||
def build_skills(quantity=1):
|
||||
@ -48,16 +43,10 @@ def build_domains(quantity=1):
|
||||
return [Domain(faker.words(6), faker.text()) for _ in range(quantity)]
|
||||
|
||||
|
||||
def build_tribe_assessment_exercise_question(
|
||||
tribe_qty=1,
|
||||
assessment_per_tribe=1,
|
||||
exercise_per_assessment=1,
|
||||
def build_questions(
|
||||
exercises: list[Exercise],
|
||||
question_per_exercise=1,
|
||||
):
|
||||
tribes, assessments, exercises = build_tribe_assessment_exercise(
|
||||
tribe_qty, assessment_per_tribe, exercise_per_assessment
|
||||
)
|
||||
|
||||
skills = build_skills()
|
||||
domains = build_domains()
|
||||
|
||||
@ -76,4 +65,4 @@ def build_tribe_assessment_exercise_question(
|
||||
for _ in range(question_per_exercise)
|
||||
]
|
||||
|
||||
return tribes, assessments, exercises, questions
|
||||
return questions
|
||||
|
@ -1,16 +1,15 @@
|
||||
from random import choice, randint
|
||||
|
||||
from .fakes import (
|
||||
build_tribe_assessment_exercise,
|
||||
build_tribe_assessment_exercise_question,
|
||||
)
|
||||
from tests.model.fakes import build_questions
|
||||
|
||||
from .fakes import build_assessments, build_exercises, build_tribes
|
||||
|
||||
|
||||
def test_assessement_register_exercise():
|
||||
exercise_qty = randint(1, 10)
|
||||
tribes, assessments, exercises = build_tribe_assessment_exercise(
|
||||
exercise_per_assessment=exercise_qty
|
||||
)
|
||||
tribes = build_tribes(1)
|
||||
assessments = build_assessments(tribes, 1)
|
||||
exercises = build_exercises(assessments, exercise_qty)
|
||||
|
||||
assert len(assessments[0].exercises) == exercise_qty
|
||||
assert assessments[0].exercises == exercises
|
||||
@ -18,12 +17,10 @@ def test_assessement_register_exercise():
|
||||
|
||||
def test_exercise_register_question():
|
||||
question_qty = randint(1, 10)
|
||||
(
|
||||
tribes,
|
||||
assessments,
|
||||
exercises,
|
||||
questions,
|
||||
) = build_tribe_assessment_exercise_question(question_per_exercise=question_qty)
|
||||
tribes = build_tribes(1)
|
||||
assessments = build_assessments(tribes, 1)
|
||||
exercises = build_exercises(assessments, 1)
|
||||
questions = build_questions(exercises, question_qty)
|
||||
|
||||
assert len(exercises[0].questions) == question_qty
|
||||
assert exercises[0].questions == questions
|
||||
|
@ -2,12 +2,13 @@ from random import randint
|
||||
|
||||
from backend.model.student import Student
|
||||
from backend.model.tribe import Tribe
|
||||
from tests.model.fakes import build_tribe_assessment
|
||||
from tests.model.fakes import build_assessments, build_tribes
|
||||
|
||||
|
||||
def test_tribe_register_assessment():
|
||||
assessments_qty = randint(1, 10)
|
||||
tribes, assessments = build_tribe_assessment(assessment_per_tribe=assessments_qty)
|
||||
tribes = build_tribes(1)
|
||||
assessments = build_assessments(tribes, assessments_qty)
|
||||
|
||||
assert len(tribes[0].assessments) == assessments_qty
|
||||
assert tribes[0].assessments == assessments
|
||||
|
Loading…
Reference in New Issue
Block a user