示例#1
0
    def test_draw_hint_member_free_text(self):
        am = AttributeManager(self.description, ['first_name'])
        bm = AttributeManager('first_name', [])

        for i in range(4):
            member = Member(i, first_name=str(i), last_name=str(i))
            am.register_member(member)
            bm.register_member(member)

            member = Member(i + 10, first_name=str(i))
            am.register_member(member)
            bm.register_member(member)

            member = Member(i + 20, last_name=str(i))
            am.register_member(member)
            bm.register_member(member)

        member = Member(100, first_name='A', last_name='B')
        am.register_member(member)
        bm.register_member(member)

        member = am.draw_hint_member(bm, multiple_choice=False)
        assert member.last_name and member.first_name
        assert member in am.available_members
        assert member in bm.available_members
        assert am.is_hintable_with_member(bm, member, multiple_choice=False)
        assert len(am.unique_attributes_of(member)) >= 1
示例#2
0
    def test_is_hintable_with_member_free_text(self):
        am = AttributeManager(self.description, [])
        bm = AttributeManager('first_name', [])

        for i in range(10):
            am.register_member(Member(i, first_name='a', last_name='b'))
            bm.register_member(Member(i, first_name='a', last_name='b'))

        assert not bm.is_hintable_with_member(
            am,
            Member(100, first_name='a', last_name='b'),
            multiple_choice=False)

        member = Member(100, first_name='c', last_name='b')
        am.register_member(member)
        bm.register_member(member)
        assert bm.is_hintable_with_member(am, member, multiple_choice=False)
示例#3
0
    def test_is_hintable_with_member(self):
        am = AttributeManager(self.description, [])
        bm = AttributeManager('first_name', [])

        for i in range(10):
            am.register_member(Member(i, first_name='a', last_name='b'))

        assert not bm.is_hintable_with_member(
            am, Member(100, first_name='a', last_name='b'))
        assert not bm.is_hintable_with_member(
            am, Member(100, first_name='c', last_name='b'))

        for i in range(5):
            am.register_member(Member(i + 10, first_name=str(i),
                                      last_name='b'))

        assert not bm.is_hintable_with_member(
            am, Member(100, first_name='a', last_name='b'))
        assert not bm.is_hintable_with_member(
            am, Member(100, first_name='c', last_name='b'))

        for i in range(5):
            am.register_member(Member(i + 20, first_name='a',
                                      last_name=str(i)))

        assert not bm.is_hintable_with_member(
            am, Member(100, first_name='a', last_name='b'))
        assert bm.is_hintable_with_member(
            am, Member(100, first_name='c', last_name='b'))
示例#4
0
    def test_draw_hint_member(self, runs):
        am = AttributeManager(self.description, ['first_name'])
        bm = AttributeManager('first_name', [])

        for i in range(4):
            member = Member(i, first_name=str(i), last_name=str(i))
            am.register_member(member)
            bm.register_member(member)

            member = Member(i + 10, first_name=str(i))
            am.register_member(member)
            bm.register_member(member)

            member = Member(i + 20, last_name=str(i))
            am.register_member(member)
            bm.register_member(member)

        member = am.draw_hint_member(bm, exclude_members=[Member(0)])
        assert member != Member(0)
        assert member.last_name and member.first_name
        assert member in am.available_members
        assert member in bm.available_members
        assert am.is_hintable_with_member(bm, member)
        assert len(bm.distinct_values_for_member(am, member)) >= 3