def test_serialize_with_empty_courses(self): period = Period( major_id=None, name="Period B", is_detail=True, courses=[], ) serialized_period = period.serialize() assert serialized_period["name"] == period.name assert serialized_period["is_detail"] == period.is_detail assert serialized_period["courses"] == []
def test_serialization_contains_required_keys(self): period = Period( major_id=None, name="Period A", is_detail=True, courses=[], ) serialized_period = period.serialize() self.assert_serialization_contains_keys( keys=["name", "is_detail", "courses"], serialized_object=serialized_period )
def test_serialize_with_courses(self): period = Period( major_id=None, name="Period C", is_detail=True, courses=[self.generate_random_course_item() for _ in range(5)], ) serialized_period = period.serialize() assert serialized_period["name"] == period.name assert serialized_period["is_detail"] == period.is_detail for i in range(len(serialized_period["courses"])): assert serialized_period["courses"][i] == period.courses[i].serialize()