34 lines
999 B
Python
34 lines
999 B
Python
from random import randint
|
|
|
|
import pytest
|
|
|
|
from backend.model.student import Student
|
|
from backend.model.tribe import Tribe, TribeError
|
|
from tests.model.fakes import build_assessments, build_tribes
|
|
|
|
|
|
def test_tribe_register_assessment():
|
|
assessments_qty = randint(1, 10)
|
|
tribes = build_tribes(1)
|
|
assessments = build_assessments(tribes, assessments_qty)
|
|
|
|
assert len(tribes[0].assessments) == assessments_qty
|
|
assert tribes[0].assessments == assessments
|
|
|
|
|
|
def test_tribe_register_student():
|
|
tribe = Tribe("foo", "2nd")
|
|
student = Student(id="1", name="Bob", tribe=tribe)
|
|
|
|
assert len(tribe.students) == 1
|
|
assert tribe.students[0] == student
|
|
|
|
|
|
def test_tribe_register_student_already_exists_overwrite():
|
|
tribe = Tribe("foo", "2nd")
|
|
student = Student(id="1", name="Bob", tribe=tribe)
|
|
changed_student = Student(id="1", name="Choupy", tribe=tribe)
|
|
|
|
assert tribe.students[0] == changed_student
|
|
assert student.name not in [s.name for s in tribe.students]
|