from frametree.axes.medimage import MedImage


def test_is_parent():
    assert not MedImage.session.is_parent(MedImage.session)
    assert not MedImage.session.is_parent(MedImage.subject)
    assert not MedImage.session.is_parent(MedImage.member)
    assert not MedImage.session.is_parent(MedImage.group)
    assert not MedImage.session.is_parent(MedImage.visit)
    assert not MedImage.session.is_parent(MedImage.groupedvisit)
    assert not MedImage.session.is_parent(MedImage.matchedvisit)
    assert not MedImage.session.is_parent(MedImage.constant)

    assert MedImage.member.is_parent(MedImage.session)
    assert MedImage.member.is_parent(MedImage.subject)
    assert not MedImage.member.is_parent(MedImage.member)
    assert not MedImage.member.is_parent(MedImage.group)
    assert not MedImage.member.is_parent(MedImage.visit)
    assert not MedImage.member.is_parent(MedImage.groupedvisit)
    assert MedImage.member.is_parent(MedImage.matchedvisit)
    assert not MedImage.member.is_parent(MedImage.constant)

    assert MedImage.group.is_parent(MedImage.session)
    assert MedImage.group.is_parent(MedImage.subject)
    assert not MedImage.group.is_parent(MedImage.member)
    assert not MedImage.group.is_parent(MedImage.group)
    assert not MedImage.group.is_parent(MedImage.visit)
    assert MedImage.group.is_parent(MedImage.groupedvisit)
    assert not MedImage.group.is_parent(MedImage.matchedvisit)
    assert not MedImage.group.is_parent(MedImage.constant)

    assert MedImage.visit.is_parent(MedImage.session)
    assert not MedImage.visit.is_parent(MedImage.subject)
    assert not MedImage.visit.is_parent(MedImage.member)
    assert not MedImage.visit.is_parent(MedImage.group)
    assert not MedImage.visit.is_parent(MedImage.visit)
    assert MedImage.visit.is_parent(MedImage.groupedvisit)
    assert MedImage.visit.is_parent(MedImage.matchedvisit)
    assert not MedImage.visit.is_parent(MedImage.constant)

    assert MedImage.subject.is_parent(MedImage.session)
    assert not MedImage.subject.is_parent(MedImage.subject)
    assert not MedImage.subject.is_parent(MedImage.member)
    assert not MedImage.subject.is_parent(MedImage.group)
    assert not MedImage.subject.is_parent(MedImage.visit)
    assert not MedImage.subject.is_parent(MedImage.groupedvisit)
    assert not MedImage.subject.is_parent(MedImage.matchedvisit)
    assert not MedImage.subject.is_parent(MedImage.constant)

    assert MedImage.groupedvisit.is_parent(MedImage.session)
    assert not MedImage.groupedvisit.is_parent(MedImage.subject)
    assert not MedImage.groupedvisit.is_parent(MedImage.member)
    assert not MedImage.groupedvisit.is_parent(MedImage.group)
    assert not MedImage.groupedvisit.is_parent(MedImage.visit)
    assert not MedImage.groupedvisit.is_parent(MedImage.groupedvisit)
    assert not MedImage.groupedvisit.is_parent(MedImage.matchedvisit)
    assert not MedImage.groupedvisit.is_parent(MedImage.constant)

    assert MedImage.matchedvisit.is_parent(MedImage.session)
    assert not MedImage.matchedvisit.is_parent(MedImage.subject)
    assert not MedImage.matchedvisit.is_parent(MedImage.member)
    assert not MedImage.matchedvisit.is_parent(MedImage.group)
    assert not MedImage.matchedvisit.is_parent(MedImage.visit)
    assert not MedImage.matchedvisit.is_parent(MedImage.groupedvisit)
    assert not MedImage.matchedvisit.is_parent(MedImage.matchedvisit)
    assert not MedImage.matchedvisit.is_parent(MedImage.constant)

    assert MedImage.constant.is_parent(MedImage.session)
    assert MedImage.constant.is_parent(MedImage.subject)
    assert MedImage.constant.is_parent(MedImage.member)
    assert MedImage.constant.is_parent(MedImage.group)
    assert MedImage.constant.is_parent(MedImage.visit)
    assert MedImage.constant.is_parent(MedImage.groupedvisit)
    assert MedImage.constant.is_parent(MedImage.matchedvisit)
    assert not MedImage.constant.is_parent(MedImage.constant)
