Exemplo n.º 1
0
    def test_three_teachers_three_students(self, db):
        rel1 = factories.RelationshipFactory.create(
            to_profile__name=u"Frankie")
        rel2 = factories.RelationshipFactory.create(
            from_profile=rel1.from_profile,
            to_profile__name=u"Maria",
            )
        rel3 = factories.RelationshipFactory.create(
            from_profile=rel1.from_profile,
            to_profile__name=u"Juan",
            )
        factories.RelationshipFactory.create(
            to_profile=rel1.to_profile,
            from_profile__name=u"Mrs. Dodd",
            from_profile__school_staff=True,
            )
        factories.RelationshipFactory.create(
            to_profile=rel2.to_profile,
            from_profile__name=u"Mr. Todd",
            from_profile__school_staff=True,
            )
        factories.RelationshipFactory.create(
            to_profile=rel3.to_profile,
            from_profile__name=u"Ms. Codd",
            from_profile__school_staff=True,
            )

        res = hook.interpolate_teacher_names(u'%s', rel1.elder)

        assert res == u"your students' teachers"
Exemplo n.º 2
0
    def test_one_teacher(self, db):
        parent_rel = factories.RelationshipFactory.create()
        factories.RelationshipFactory.create(
            to_profile=parent_rel.to_profile,
            from_profile__name="Mrs. Dodd",
            from_profile__school_staff=True,
            )

        res = hook.interpolate_teacher_names(u'%s', parent_rel.elder)

        assert res == u"Mrs. Dodd"
Exemplo n.º 3
0
    def test_one_teacher_one_student_too_long(self, db):
        parent_rel = factories.RelationshipFactory.create(
            to_profile__name=u"Frankie")
        factories.RelationshipFactory.create(
            to_profile=parent_rel.to_profile,
            from_profile__name=u"Mrs. Doddkerstein-Schnitzelberger",
            from_profile__school_staff=True,
            )
        prefix = (u'a' * 140)
        res = hook.interpolate_teacher_names(
            prefix + '%s', parent_rel.elder)

        assert res == prefix + u"Frankie's teacher"
Exemplo n.º 4
0
    def test_two_teachers_two_students(self, db):
        rel1 = factories.RelationshipFactory.create()
        rel2 = factories.RelationshipFactory.create(from_profile=rel1.elder)
        factories.RelationshipFactory.create(
            to_profile=rel1.to_profile,
            from_profile__name=u"Mrs. Dodd",
            from_profile__school_staff=True,
            )
        factories.RelationshipFactory.create(
            to_profile=rel2.to_profile,
            from_profile__name=u"Mr. Todd",
            from_profile__school_staff=True,
            )

        res = hook.interpolate_teacher_names(u'%s', rel1.elder)

        assert res in {u"Mrs. Dodd & Mr. Todd", u"Mr. Todd & Mrs. Dodd"}
Exemplo n.º 5
0
    def test_everything_too_long(self, db):
        """If all options are too long, take the best regardless of length."""
        parent_rel = factories.RelationshipFactory.create(
            to_profile__name=u"Frankie")
        factories.RelationshipFactory.create(
            to_profile=parent_rel.to_profile,
            from_profile__name=u"Mrs. Dodd",
            from_profile__school_staff=True,
            )
        factories.RelationshipFactory.create(
            to_profile=parent_rel.to_profile,
            from_profile__name=u"Mr. Todd",
            from_profile__school_staff=True,
            )
        prefix = (u'a' * 155)
        res = hook.interpolate_teacher_names(
            prefix + '%s', parent_rel.elder)

        assert res in {
            prefix + u"Mrs. Dodd & Mr. Todd",
            prefix + u"Mr. Todd & Mrs. Dodd",
            }
Exemplo n.º 6
0
    def test_three_teachers_one_student(self, db):
        parent_rel = factories.RelationshipFactory.create(
            to_profile__name=u"Frankie")
        factories.RelationshipFactory.create(
            to_profile=parent_rel.to_profile,
            from_profile__name=u"Mrs. Dodd",
            from_profile__school_staff=True,
            )
        factories.RelationshipFactory.create(
            to_profile=parent_rel.to_profile,
            from_profile__name=u"Mr. Todd",
            from_profile__school_staff=True,
            )
        factories.RelationshipFactory.create(
            to_profile=parent_rel.to_profile,
            from_profile__name=u"Ms. Codd",
            from_profile__school_staff=True,
            )

        res = hook.interpolate_teacher_names(u'%s', parent_rel.elder)

        assert res == u"Frankie's teachers"
Exemplo n.º 7
0
    def test_no_students(self, db):
        parent = factories.ProfileFactory.create()

        res = hook.interpolate_teacher_names(u'%s', parent)

        assert res == u"teachers"