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()
|
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)]
|
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):
|
def build_assessments(tribes: list[Tribe], assessment_per_tribe: int = 1):
|
||||||
tribes = build_tribes(tribe_qty)
|
|
||||||
|
|
||||||
assessments = []
|
assessments = []
|
||||||
for t in tribes:
|
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)
|
for _ in range(assessment_per_tribe)
|
||||||
]
|
]
|
||||||
|
|
||||||
return tribes, assessments
|
return assessments
|
||||||
|
|
||||||
|
|
||||||
def build_tribe_assessment_exercise(
|
def build_exercises(assessments: list[Assessment], exercise_per_assessment=1):
|
||||||
tribe_qty=1, assessment_per_tribe=1, exercise_per_assessment=1
|
|
||||||
):
|
|
||||||
tribes, assessments = build_tribe_assessment(tribe_qty, assessment_per_tribe)
|
|
||||||
|
|
||||||
exercises = []
|
exercises = []
|
||||||
for assessment in assessments:
|
for assessment in assessments:
|
||||||
exercises += [
|
exercises += [
|
||||||
@ -37,7 +32,7 @@ def build_tribe_assessment_exercise(
|
|||||||
for _ in range(exercise_per_assessment)
|
for _ in range(exercise_per_assessment)
|
||||||
]
|
]
|
||||||
|
|
||||||
return tribes, assessments, exercises
|
return exercises
|
||||||
|
|
||||||
|
|
||||||
def build_skills(quantity=1):
|
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)]
|
return [Domain(faker.words(6), faker.text()) for _ in range(quantity)]
|
||||||
|
|
||||||
|
|
||||||
def build_tribe_assessment_exercise_question(
|
def build_questions(
|
||||||
tribe_qty=1,
|
exercises: list[Exercise],
|
||||||
assessment_per_tribe=1,
|
|
||||||
exercise_per_assessment=1,
|
|
||||||
question_per_exercise=1,
|
question_per_exercise=1,
|
||||||
):
|
):
|
||||||
tribes, assessments, exercises = build_tribe_assessment_exercise(
|
|
||||||
tribe_qty, assessment_per_tribe, exercise_per_assessment
|
|
||||||
)
|
|
||||||
|
|
||||||
skills = build_skills()
|
skills = build_skills()
|
||||||
domains = build_domains()
|
domains = build_domains()
|
||||||
|
|
||||||
@ -76,4 +65,4 @@ def build_tribe_assessment_exercise_question(
|
|||||||
for _ in range(question_per_exercise)
|
for _ in range(question_per_exercise)
|
||||||
]
|
]
|
||||||
|
|
||||||
return tribes, assessments, exercises, questions
|
return questions
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
from random import choice, randint
|
from random import choice, randint
|
||||||
|
|
||||||
from .fakes import (
|
from tests.model.fakes import build_questions
|
||||||
build_tribe_assessment_exercise,
|
|
||||||
build_tribe_assessment_exercise_question,
|
from .fakes import build_assessments, build_exercises, build_tribes
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_assessement_register_exercise():
|
def test_assessement_register_exercise():
|
||||||
exercise_qty = randint(1, 10)
|
exercise_qty = randint(1, 10)
|
||||||
tribes, assessments, exercises = build_tribe_assessment_exercise(
|
tribes = build_tribes(1)
|
||||||
exercise_per_assessment=exercise_qty
|
assessments = build_assessments(tribes, 1)
|
||||||
)
|
exercises = build_exercises(assessments, exercise_qty)
|
||||||
|
|
||||||
assert len(assessments[0].exercises) == exercise_qty
|
assert len(assessments[0].exercises) == exercise_qty
|
||||||
assert assessments[0].exercises == exercises
|
assert assessments[0].exercises == exercises
|
||||||
@ -18,12 +17,10 @@ def test_assessement_register_exercise():
|
|||||||
|
|
||||||
def test_exercise_register_question():
|
def test_exercise_register_question():
|
||||||
question_qty = randint(1, 10)
|
question_qty = randint(1, 10)
|
||||||
(
|
tribes = build_tribes(1)
|
||||||
tribes,
|
assessments = build_assessments(tribes, 1)
|
||||||
assessments,
|
exercises = build_exercises(assessments, 1)
|
||||||
exercises,
|
questions = build_questions(exercises, question_qty)
|
||||||
questions,
|
|
||||||
) = build_tribe_assessment_exercise_question(question_per_exercise=question_qty)
|
|
||||||
|
|
||||||
assert len(exercises[0].questions) == question_qty
|
assert len(exercises[0].questions) == question_qty
|
||||||
assert exercises[0].questions == questions
|
assert exercises[0].questions == questions
|
||||||
|
@ -2,12 +2,13 @@ from random import randint
|
|||||||
|
|
||||||
from backend.model.student import Student
|
from backend.model.student import Student
|
||||||
from backend.model.tribe import Tribe
|
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():
|
def test_tribe_register_assessment():
|
||||||
assessments_qty = randint(1, 10)
|
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 len(tribes[0].assessments) == assessments_qty
|
||||||
assert tribes[0].assessments == assessments
|
assert tribes[0].assessments == assessments
|
||||||
|
Loading…
Reference in New Issue
Block a user