refact: move Tribe to own file and rename tools to fakes

This commit is contained in:
Bertrand Benjamin 2022-12-20 08:28:45 +01:00
parent 67b9a1e8a0
commit 4f4fc53253
6 changed files with 30 additions and 21 deletions

View File

@ -5,7 +5,7 @@ from datetime import date
from typing import TYPE_CHECKING, Optional
if TYPE_CHECKING:
from backend.model.student import Tribe
from backend.model.tribe import Tribe
class Assessment:

View File

@ -1,24 +1,10 @@
from __future__ import annotations
from dataclasses import dataclass, field
from dataclasses import dataclass
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from backend.model.assessment import Assessment
@dataclass
class Tribe:
name: str
level: str
students: list[Student] = field(default_factory=list)
assessments: list[Assessment] = field(default_factory=list)
def register_assessment(self, assessment: Assessment) -> None:
self.assessments.append(assessment)
def register_student(self, student: Student) -> None:
self.students.append(student)
from backend.model.tribe import Tribe
@dataclass

22
backend/model/tribe.py Normal file
View File

@ -0,0 +1,22 @@
from __future__ import annotations
from dataclasses import dataclass, field
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from backend.model.assessment import Assessment
from backend.model.student import Student
@dataclass
class Tribe:
name: str
level: str
students: list[Student] = field(default_factory=list)
assessments: list[Assessment] = field(default_factory=list)
def register_assessment(self, assessment: Assessment) -> None:
self.assessments.append(assessment)
def register_student(self, student: Student) -> None:
self.students.append(student)

View File

@ -3,7 +3,7 @@ from random import choice, randint
from faker import Faker
from backend.model.assessment import Assessment, Domain, Exercise, Question, Skill
from backend.model.student import Tribe
from backend.model.tribe import Tribe
faker = Faker()

View File

@ -1,6 +1,6 @@
from random import choice, randint
from .tools import (
from .fakes import (
build_tribe_assessment_exercise,
build_tribe_assessment_exercise_question,
)

View File

@ -1,7 +1,8 @@
from random import randint
from backend.model.student import Student, Tribe
from tests.model.tools import build_tribe_assessment
from backend.model.student import Student
from backend.model.tribe import Tribe
from tests.model.fakes import build_tribe_assessment
def test_tribe_register_assessment():